?? forwcomptransfspec.java
字號:
} // Check that default value has been specified if(getDefault()==null){ int ndefspec = 0; for(int t=nt-1; t>=0; t--){ for(int c=nc-1; c>=0 ; c--){ if(specValType[t][c] == SPEC_DEF){ ndefspec++; } } } // If some tile-component have received no specification, it takes // the default value defined in ParameterList if(ndefspec!=0){ param = pl.getDefaultParameterList().getParameter("Mct"); if(param==null){ if(nc==3) { AnWTFilter[][] anfilt; int[] filtType = new int[nComp]; for(int c=0;c<nComp; c++){ anfilt = (AnWTFilter[][])wfs.getCompDef(c); filtType[c] = anfilt[0][0].getFilterType(); } // Check that all filters are the same one boolean reject = false; for(int c=1; c<nComp;c++){ if(filtType[c]!=filtType[0]) reject = true; } if(reject) param = "off"; else param = "on"; } else param = "off"; if(param.equals("off")){ setDefault("none"); } else if(param.equals("on")){ if(nc<3) throw new IllegalArgumentException("Cannot use "+ "component"+ " transformation"+ " with "+ "less than 3 "+ "components"+ " within the image"); // Chose component transformation depending on wavelet // filters used int filtType = getFilterType(-1,wfs); switch(filtType){ case FilterTypes.W5X3: setDefault("rct"); return; case FilterTypes.W9X7: setDefault("ict"); return; default: throw new IllegalArgumentException("Default filter is "+ "not JPEG 2000 part"+ " I compliant"); } } else{ throw new IllegalArgumentException("Default parameter of "+ "option Mct not"+ " recognized: "+param); } } else if(param.equals("off")){ setDefault("none"); } else if(param.equals("on")){ if(nc<3) throw new IllegalArgumentException("Cannot use "+ "component"+ " transformation "+ "with "+ "less than 3 "+ "components"+ " within the "+ "image"); int filterType = getFilterType(-1,wfs); switch(filterType){ case FilterTypes.W5X3: setDefault("rct"); return; case FilterTypes.W9X7: setDefault("ict"); return; default: throw new IllegalArgumentException("Default filter"+ " is "+ "not JPEG 2000"+ " part"+ " I compliant"); } } else{ throw new IllegalArgumentException("Default parameter of "+ "option Mct not"+ " recognized: "+param); } } else{ // All tile-component have been specified, takes the first // tile-component value as default. setDefault(getTileCompVal(0,0)); switch(specValType[0][0]){ case SPEC_TILE_DEF: for(int c=nc-1; c>=0; c--){ if(specValType[0][c]==SPEC_TILE_DEF) specValType[0][c] = SPEC_DEF; } tileDef[0] = null; break; case SPEC_COMP_DEF: for(int t=nt-1; t>=0; t--){ if(specValType[t][0]==SPEC_COMP_DEF) specValType[t][0] = SPEC_DEF; } compDef[0] = null; break; case SPEC_TILE_COMP: specValType[0][0] = SPEC_DEF; tileCompVal.put("t0c0",null); break; } } } // Check validity of component transformation of each tile compared to // the filter used. for(int t=nt-1; t>=0; t--){ if(((String)getTileDef(t)).equals("none")){ // No comp. transf is used. No check is needed continue; } else if(((String)getTileDef(t)).equals("rct")){ // Tile is using Reversible component transform int filterType = getFilterType(t,wfs); switch(filterType){ case FilterTypes.W5X3: // OK break; case FilterTypes.W9X7: // Must use ICT if(isTileSpecified(t)){ // User has requested RCT -> Error throw new IllegalArgumentException("Cannot use RCT "+ "with 9x7 filter "+ "in tile "+t); } else{ // Specify ICT for this tile setTileDef(t,"ict"); } break; default: throw new IllegalArgumentException("Default filter is "+ "not JPEG 2000 part"+ " I compliant"); } } else{ // ICT int filterType = getFilterType(t,wfs); switch(filterType){ case FilterTypes.W5X3: // Must use RCT if(isTileSpecified(t)){ // User has requested ICT -> Error throw new IllegalArgumentException("Cannot use ICT "+ "with filter 5x3 "+ "in tile "+t); } else{ setTileDef(t,"rct"); } break; case FilterTypes.W9X7: // OK break; default: throw new IllegalArgumentException("Default filter is "+ "not JPEG 2000 part"+ " I compliant"); } } } } /** Get the filter type common to all component of a given tile. If the * tile index is -1, it searches common filter type of default * specifications. * * @param t The tile index * * @param wfs The analysis filters specifications * * @return The filter type common to all the components * */ private int getFilterType(int t, AnWTFilterSpec wfs){ AnWTFilter[][] anfilt; int[] filtType = new int[nComp]; for(int c=0;c<nComp; c++){ if(t==-1) anfilt = (AnWTFilter[][])wfs.getCompDef(c); else anfilt = (AnWTFilter[][])wfs.getTileCompVal(t,c); filtType[c] = anfilt[0][0].getFilterType(); } // Check that all filters are the same one boolean reject = false; for(int c=1; c<nComp;c++){ if(filtType[c]!=filtType[0]) reject = true; } if(reject){ throw new IllegalArgumentException("Can not use component"+ " transformation when "+ "components do not use "+ "the same filters"); } return filtType[0]; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -