Example #1
0
		/// <summary> Creates a ROIScaler object. The Quantizer is the source of data to
		/// scale.
		/// 
		/// <p>The ROI Scaler creates a ROIMaskGenerator depending on what ROI
		/// information is in the ParameterList. If only rectangular ROI are used,
		/// the fast mask generator for rectangular ROI can be used.</p>
		/// 
		/// </summary>
		/// <param name="src">The source of data to scale
		/// 
		/// </param>
		/// <param name="pl">The parameter list (or options).
		/// 
		/// </param>
		/// <param name="encSpec">The encoder specifications for addition of roi specs
		/// 
		/// </param>
		/// <exception cref="IllegalArgumentException">If an error occurs while parsing
		/// the options in 'pl'
		/// 
		/// </exception>
		public static ROIScaler createInstance(Quantizer src, ParameterList pl, EncoderSpecs encSpec)
		{
			System.Collections.ArrayList roiVector = System.Collections.ArrayList.Synchronized(new System.Collections.ArrayList(10));
			ROIMaskGenerator maskGen = null;
			
			// Check parameters
			pl.checkList(OPT_PREFIX, CSJ2K.j2k.util.ParameterList.toNameArray(pinfo));
			
			// Get parameters and check if there are and ROIs specified 
			System.String roiopt = pl.getParameter("Rroi");
			if (roiopt == null)
			{
				// No ROIs specified! Create ROIScaler with no mask generator
				return new ROIScaler(src, null, false, - 1, false, encSpec);
			}
			
			// Check if the lowest resolution levels should belong to the ROI 
			int sLev = pl.getIntParameter("Rstart_level");
			
			// Check if the ROIs are block-aligned
			bool useBlockAligned = pl.getBooleanParameter("Ralign");
			
			// Check if generic mask generation is specified 
			bool onlyRect = !pl.getBooleanParameter("Rno_rect");
			
			// Parse the ROIs
			parseROIs(roiopt, src.NumComps, roiVector);
			ROI[] roiArray = new ROI[roiVector.Count];
			roiVector.CopyTo(roiArray);
			
			// If onlyRect has been forced, check if there are any non-rectangular
			// ROIs specified.  Currently, only the presence of circular ROIs will
			// make this false
			if (onlyRect)
			{
				for (int i = roiArray.Length - 1; i >= 0; i--)
					if (!roiArray[i].rect)
					{
						onlyRect = false;
						break;
					}
			}
			
			if (onlyRect)
			{
				// It's possible to use the fast ROI mask generation when only
				// rectangular ROIs are specified.
				maskGen = new RectROIMaskGenerator(roiArray, src.NumComps);
			}
			else
			{
				// It's necessary to use the generic mask generation
				maskGen = new ArbROIMaskGenerator(roiArray, src.NumComps, src);
			}
			return new ROIScaler(src, maskGen, true, sLev, useBlockAligned, encSpec);
		}
Example #2
0
		/// <summary> The constructor of the arbitrary mask generator
		/// 
		/// </summary>
		/// <param name="rois">The ROI info.
		/// 
		/// </param>
		/// <param name="nrc">The number of components
		/// 
		/// </param>
		/// <param name="src">The quantizer module
		/// 
		/// </param>
		public ArbROIMaskGenerator(ROI[] rois, int nrc, Quantizer src):base(rois, nrc)
		{
			roiMask = new int[nrc][];
			this.src = src;
		}
Example #3
0
		/// <summary> Constructor of the ROI scaler, takes a Quantizer as source of data to
		/// scale.
		/// 
		/// </summary>
		/// <param name="src">The quantizer that is the source of data.
		/// 
		/// </param>
		/// <param name="mg">The mask generator that will be used for all components
		/// 
		/// </param>
		/// <param name="roi">Flag indicating whether there are rois specified.
		/// 
		/// </param>
		/// <param name="sLev">The resolution levels that belong entirely to ROI
		/// 
		/// </param>
		/// <param name="uba">Flag indicating whether block aligning is used.
		/// 
		/// </param>
		/// <param name="encSpec">The encoder specifications for addition of roi specs
		/// 
		/// </param>
		public ROIScaler(Quantizer src, ROIMaskGenerator mg, bool roi, int sLev, bool uba, EncoderSpecs encSpec):base(src)
		{
			this.src = src;
			this.roi = roi;
			this.useStartLevel = sLev;
			if (roi)
			{
				// If there is no ROI, no need to do this
				this.mg = mg;
				roiMask = new DataBlkInt();
				calcMaxMagBits(encSpec);
				blockAligned = uba;
			}
		}