001/*
002 * $RCSfile: SubbandRectROIMask.java,v $
003 * $Revision: 1.1 $
004 * $Date: 2005/02/11 05:02:24 $
005 * $State: Exp $
006 *
007 * Class:                   ROI
008 *
009 * Description:             This class describes the ROI mask for a subband
010 *
011 *
012 *
013 * COPYRIGHT:
014 *
015 * This software module was originally developed by Raphaël Grosbois and
016 * Diego Santa Cruz (Swiss Federal Institute of Technology-EPFL); Joel
017 * Askelöf (Ericsson Radio Systems AB); and Bertrand Berthelot, David
018 * Bouchard, Félix Henry, Gerard Mozelle and Patrice Onno (Canon Research
019 * Centre France S.A) in the course of development of the JPEG2000
020 * standard as specified by ISO/IEC 15444 (JPEG 2000 Standard). This
021 * software module is an implementation of a part of the JPEG 2000
022 * Standard. Swiss Federal Institute of Technology-EPFL, Ericsson Radio
023 * Systems AB and Canon Research Centre France S.A (collectively JJ2000
024 * Partners) agree not to assert against ISO/IEC and users of the JPEG
025 * 2000 Standard (Users) any of their rights under the copyright, not
026 * including other intellectual property rights, for this software module
027 * with respect to the usage by ISO/IEC and Users of this software module
028 * or modifications thereof for use in hardware or software products
029 * claiming conformance to the JPEG 2000 Standard. Those intending to use
030 * this software module in hardware or software products are advised that
031 * their use may infringe existing patents. The original developers of
032 * this software module, JJ2000 Partners and ISO/IEC assume no liability
033 * for use of this software module or modifications thereof. No license
034 * or right to this software module is granted for non JPEG 2000 Standard
035 * conforming products. JJ2000 Partners have full right to use this
036 * software module for his/her own purpose, assign or donate this
037 * software module to any third party and to inhibit third parties from
038 * using this software module for non JPEG 2000 Standard conforming
039 * products. This copyright notice must be included in all copies or
040 * derivative works of this software module.
041 *
042 * Copyright (c) 1999/2000 JJ2000 Partners.
043 * */
044package jj2000.j2k.roi.encoder;
045
046import jj2000.j2k.wavelet.Subband;
047import jj2000.j2k.wavelet.WaveletFilter;
048
049/**
050 * This class describes the ROI mask for a single subband. Each object of the
051 * class contains the mask for a particular subband and also has references to
052 * the masks of the children subbands of the subband corresponding to this
053 * mask. This class describes subband masks for images containing only
054 * rectangular ROIS
055 * */
056public class SubbandRectROIMask extends SubbandROIMask{
057
058    /** The upper left x coordinates of the applicable ROIs */
059    public int[] ulxs;
060
061    /** The upper left y coordinates of the applicable ROIs */
062    public int[] ulys;
063
064    /** The lower right x coordinates of the applicable ROIs */
065    public int[] lrxs;
066
067    /** The lower right y coordinates of the applicable ROIs */
068    public int[] lrys;
069
070    /**
071     * The constructor of the SubbandROIMask takes the dimensions of the
072     * subband as parameters. A tree of masks is generated from the subband
073     * sb. Each Subband contains the boundaries of each ROI.
074     *
075     * @param sb The subband corresponding to this Subband Mask
076     *
077     * @param ulxs The upper left x coordinates of the ROIs
078     *
079     * @param ulys The upper left y coordinates of the ROIs
080     *
081     * @param lrxs The lower right x coordinates of the ROIs
082     *
083     * @param lrys The lower right y coordinates of the ROIs
084     *
085     * @param lrys The lower right y coordinates of the ROIs
086     *
087     * @param nr Number of ROIs that affect this tile
088     * */
089    public SubbandRectROIMask(Subband sb, int[] ulxs, int[] ulys, int[] lrxs,
090                          int[] lrys, int nr){
091        super(sb.ulx,sb.uly,sb.w,sb.h);
092        this.ulxs = ulxs;
093        this.ulys = ulys;
094        this.lrxs = lrxs;
095        this.lrys = lrys;
096        int r;
097
098        if(sb.isNode){
099            isNode=true;
100            // determine odd/even - high/low filters
101            int horEvenLow = sb.ulcx%2;
102            int verEvenLow = sb.ulcy%2;
103
104            // Get filter support lengths
105            WaveletFilter hFilter = sb.getHorWFilter();
106            WaveletFilter vFilter = sb.getVerWFilter();
107            int hlnSup = hFilter.getSynLowNegSupport();
108            int hhnSup = hFilter.getSynHighNegSupport();
109            int hlpSup = hFilter.getSynLowPosSupport();
110            int hhpSup = hFilter.getSynHighPosSupport();
111            int vlnSup = vFilter.getSynLowNegSupport();
112            int vhnSup = vFilter.getSynHighNegSupport();
113            int vlpSup = vFilter.getSynLowPosSupport();
114            int vhpSup = vFilter.getSynHighPosSupport();
115
116            // Generate arrays for children
117            int x,y;
118            int[] lulxs = new int[nr];
119            int[] lulys = new int[nr];
120            int[] llrxs = new int[nr];
121            int[] llrys = new int[nr];
122            int[] hulxs = new int[nr];
123            int[] hulys = new int[nr];
124            int[] hlrxs = new int[nr];
125            int[] hlrys = new int[nr];
126            for(r=nr-1;r>=0;r--){ // For all ROI calculate ...
127                // Upper left x for all children
128                x = ulxs[r];
129                if(horEvenLow==0){
130                    lulxs[r] = (x+1-hlnSup)/2;
131                    hulxs[r] = (x-hhnSup)/2;
132                }
133                else{
134                    lulxs[r] = (x-hlnSup)/2;
135                    hulxs[r] = (x+1-hhnSup)/2;
136                }
137                // Upper left y for all children
138                y = ulys[r];
139                if(verEvenLow==0){
140                    lulys[r] = (y+1-vlnSup)/2;
141                    hulys[r] = (y-vhnSup)/2;
142                }
143                else{
144                    lulys[r] = (y-vlnSup)/2;
145                    hulys[r] = (y+1-vhnSup)/2;
146                }
147                // lower right x for all children
148                x = lrxs[r];
149                if(horEvenLow==0){
150                    llrxs[r] = (x+hlpSup)/2;
151                    hlrxs[r] = (x-1+hhpSup)/2;
152                }
153                else{
154                    llrxs[r] = (x-1+hlpSup)/2;
155                    hlrxs[r] = (x+hhpSup)/2;
156                }
157                // lower right y for all children
158                y=lrys[r];
159                if(verEvenLow==0){
160                    llrys[r] = (y+vlpSup)/2;
161                    hlrys[r] = (y-1+vhpSup)/2;
162                }
163                else{
164                    llrys[r] = (y-1+vlpSup)/2;
165                    hlrys[r] = (y+vhpSup)/2;
166                }
167            }
168            // Create children
169            hh = new SubbandRectROIMask(sb.getHH(),hulxs,hulys,hlrxs,hlrys,nr);
170            lh = new SubbandRectROIMask(sb.getLH(),lulxs,hulys,llrxs,hlrys,nr);
171            hl = new SubbandRectROIMask(sb.getHL(),hulxs,lulys,hlrxs,llrys,nr);
172            ll = new SubbandRectROIMask(sb.getLL(),lulxs,lulys,llrxs,llrys,nr);
173
174        }
175    }
176}
177
178
179
180
181
182
183
184
185
186
187