001/* 002 * $RCSfile: SubbandROIMask.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 046 047/** 048 * This abstract class describes the ROI mask for a single subband. Each 049 * object of the class contains the mask for a particular subband and also has 050 * references to the masks of the children subbands of the subband 051 * corresponding to this mask. */ 052public abstract class SubbandROIMask{ 053 054 /** The subband masks of the child LL */ 055 protected SubbandROIMask ll; 056 057 /** The subband masks of the child LH */ 058 protected SubbandROIMask lh; 059 060 /** The subband masks of the child HL */ 061 protected SubbandROIMask hl; 062 063 /** The subband masks of the child HH */ 064 protected SubbandROIMask hh; 065 066 /** Flag indicating whether this subband mask is a node or not */ 067 protected boolean isNode; 068 069 /** Horizontal uper-left coordinate of the subband mask */ 070 public int ulx; 071 072 /** Vertical uper-left coordinate of the subband mask */ 073 public int uly; 074 075 /** Width of the subband mask */ 076 public int w; 077 078 /** Height of the subband mask */ 079 public int h; 080 081 /** 082 * The constructor of the SubbandROIMask takes the dimensions of the 083 * subband as parameters 084 * 085 * @param ulx The upper left x coordinate of corresponding subband 086 * 087 * @param uly The upper left y coordinate of corresponding subband 088 * 089 * @param w The width of corresponding subband 090 * 091 * @param h The height of corresponding subband 092 * */ 093 public SubbandROIMask(int ulx, int uly, int w, int h){ 094 this.ulx=ulx; 095 this.uly=uly; 096 this.w=w; 097 this.h=h; 098 } 099 100 /** 101 * Returns a reference to the Subband mask element to which the specified 102 * point belongs. The specified point must be inside this (i.e. the one 103 * defined by this object) subband mask. This method searches through the 104 * tree. 105 * 106 * @param x horizontal coordinate of the specified point. 107 * 108 * @param y horizontal coordinate of the specified point. 109 * */ 110 public SubbandROIMask getSubbandRectROIMask(int x, int y) { 111 SubbandROIMask cur,hhs; 112 113 // Check that we are inside this subband 114 if (x < ulx || y < uly || x >= ulx+w || y >= uly+h) { 115 throw new IllegalArgumentException(); 116 } 117 118 cur = this; 119 while (cur.isNode) { 120 hhs = cur.hh; 121 // While we are still at a node -> continue 122 if (x < hhs.ulx) { 123 // Is the result of horizontal low-pass 124 if (y < hhs.uly) { 125 // Vertical low-pass 126 cur = cur.ll; 127 } 128 else { 129 // Vertical high-pass 130 cur = cur.lh; 131 } 132 } 133 else { 134 // Is the result of horizontal high-pass 135 if (y < hhs.uly) { 136 // Vertical low-pass 137 cur = cur.hl; 138 } 139 else { 140 // Vertical high-pass 141 cur = cur.hh; 142 } 143 } 144 } 145 return cur; 146 } 147} 148 149 150 151 152 153 154 155 156 157 158