CSJ2K.j2k.roi.encoder.ROIScaler.createInstance C# (CSharp) Method

createInstance() public static method

Creates a ROIScaler object. The Quantizer is the source of data to scale.

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.

If an error occurs while parsing /// the options in 'pl' /// ///
public static createInstance ( CSJ2K.j2k.quantization.quantizer.Quantizer src, CSJ2K.j2k.util.ParameterList pl, CSJ2K.j2k.encoder.EncoderSpecs encSpec ) : ROIScaler
src CSJ2K.j2k.quantization.quantizer.Quantizer The source of data to scale /// ///
pl CSJ2K.j2k.util.ParameterList The parameter list (or options). /// ///
encSpec CSJ2K.j2k.encoder.EncoderSpecs The encoder specifications for addition of roi specs /// ///
return ROIScaler
        public static ROIScaler createInstance(Quantizer src, ParameterList pl, EncoderSpecs encSpec)
        {
            System.Collections.Generic.List<ROI> roiVector = new List<ROI>(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);
        }