private void sharpen4(AutoTypeImage image) { String name = image.getSingleBandName(); String bitwise = image.getBitWise(); String cast = image.getTypeCastFromSum(); String sumtype = image.getSumType(); out.print( "\tpublic static void sharpenInner4( " + name + " input , " + name + " output , " + sumtype + " minValue , " + sumtype + " maxValue ) {\n" + "\t\tfor( int y = 1; y < input.height-1; y++ ) {\n" + "\t\t\tint indexIn = input.startIndex + y*input.stride + 1;\n" + "\t\t\tint indexOut = output.startIndex + y*output.stride + 1;\n" + "\n" + "\t\t\tfor( int x = 1; x < input.width-1; x++ , indexIn++,indexOut++) {\n" + "\n" + "\t\t\t\t" + sumtype + " a = 5*(input.data[indexIn] " + bitwise + ") - (\n" + "\t\t\t\t\t\t(input.data[indexIn-1] " + bitwise + ")+(input.data[indexIn+1] " + bitwise + ") +\n" + "\t\t\t\t\t\t\t\t(input.data[indexIn-input.stride] " + bitwise + ") + (input.data[indexIn+input.stride] " + bitwise + "));\n" + "\n" + "\t\t\t\tif( a > maxValue )\n" + "\t\t\t\t\ta = maxValue;\n" + "\t\t\t\telse if( a < minValue )\n" + "\t\t\t\t\ta = minValue;\n" + "\n" + "\t\t\t\toutput.data[indexOut] = " + cast + "a;\n" + "\t\t\t}\n" + "\t\t}\n" + "\t}\n\n"); }
private void printTransform(AutoTypeImage imageIn, AutoTypeImage imageOut) { String sumType = imageOut.getSumType(); String bitWise = imageIn.getBitWise(); String typeCast = imageOut.getTypeCastFromSum(); out.print( "\tpublic static void transform( final " + imageIn.getSingleBandName() + " input , final " + imageOut.getSingleBandName() + " transformed )\n" + "\t{\n" + "\t\tint indexSrc = input.startIndex;\n" + "\t\tint indexDst = transformed.startIndex;\n" + "\t\tint end = indexSrc + input.width;\n" + "\n" + "\t\t" + sumType + " total = 0;\n" + "\t\tfor( ; indexSrc < end; indexSrc++ ) {\n" + "\t\t\ttransformed.data[indexDst++] = " + typeCast + "total += input.data[indexSrc]" + bitWise + ";\n" + "\t\t}\n" + "\n" + "\t\tfor( int y = 1; y < input.height; y++ ) {\n" + "\t\t\tindexSrc = input.startIndex + input.stride*y;\n" + "\t\t\tindexDst = transformed.startIndex + transformed.stride*y;\n" + "\t\t\tint indexPrev = indexDst - transformed.stride;\n" + "\n" + "\t\t\tend = indexSrc + input.width;\n" + "\n" + "\t\t\ttotal = 0;\n" + "\t\t\tfor( ; indexSrc < end; indexSrc++ ) {\n" + "\t\t\t\ttotal += input.data[indexSrc]" + bitWise + ";\n" + "\t\t\t\ttransformed.data[indexDst++] = transformed.data[indexPrev++] + total;\n" + "\t\t\t}\n" + "\t\t}\n" + "\t}\n\n"); }
private void sharpen8(AutoTypeImage image) { String name = image.getSingleBandName(); String bitwise = image.getBitWise(); String cast = image.getTypeCastFromSum(); String sumtype = image.getSumType(); out.print( "\tpublic static void sharpenInner8( " + name + " input , " + name + " output , " + sumtype + " minValue , " + sumtype + " maxValue ) {\n" + "\t\tfor( int y = 1; y < input.height-1; y++ ) {\n" + "\t\t\tint indexIn = input.startIndex + y*input.stride + 1;\n" + "\t\t\tint indexOut = output.startIndex + y*output.stride + 1;\n" + "\n" + "\t\t\tfor( int x = 1; x < input.width-1; x++ , indexIn++,indexOut++) {\n" + "\n" + "\t\t\t\t" + sumtype + " a11 = input.data[indexIn-input.stride-1] " + bitwise + ";\n" + "\t\t\t\t" + sumtype + " a12 = input.data[indexIn-input.stride] " + bitwise + ";\n" + "\t\t\t\t" + sumtype + " a13 = input.data[indexIn-input.stride+1] " + bitwise + ";\n" + "\t\t\t\t" + sumtype + " a21 = input.data[indexIn-1] " + bitwise + ";\n" + "\t\t\t\t" + sumtype + " a22 = input.data[indexIn] " + bitwise + ";\n" + "\t\t\t\t" + sumtype + " a23 = input.data[indexIn+1] " + bitwise + ";\n" + "\t\t\t\t" + sumtype + " a31 = input.data[indexIn+input.stride-1] " + bitwise + ";\n" + "\t\t\t\t" + sumtype + " a32 = input.data[indexIn+input.stride] " + bitwise + ";\n" + "\t\t\t\t" + sumtype + " a33 = input.data[indexIn+input.stride+1] " + bitwise + ";\n" + "\t\t\t\t\n" + "\t\t\t\t" + sumtype + " result = 9*a22 - (a11+a12+a13+a21+a23+a31+a32+a33);\n" + "\n" + "\t\t\t\tif( result > maxValue )\n" + "\t\t\t\t\tresult = maxValue;\n" + "\t\t\t\telse if( result < minValue )\n" + "\t\t\t\t\tresult = minValue;\n" + "\n" + "\t\t\t\toutput.data[indexOut] = " + cast + "result;\n" + "\t\t\t}\n" + "\t\t}\n" + "\t}\n\n"); }
private void sharpenBorder8(AutoTypeImage image) { String name = image.getSingleBandName(); String cast = image.getTypeCastFromSum(); String sumtype = image.getSumType(); out.print( "\tpublic static void sharpenBorder8( " + name + " input , " + name + " output , " + sumtype + " minValue , " + sumtype + " maxValue ) {\n" + "\t\t" + sumtype + " value;\n" + "\n" + "\t\tint b = input.height-1;\n" + "\t\t" + sumtype + " a11,a12,a13,a21,a22,a23,a31,a32,a33;\n" + "\n" + "\t\tint indexTop = input.startIndex;\n" + "\t\tint indexBottom = input.startIndex + b*input.stride;\n" + "\n" + "\t\tfor( int x = 0; x < input.width; x++ ) {\n" + "\n" + "\t\t\ta11 = safeGet(input,x-1,-1);\n" + "\t\t\ta12 = safeGet(input,x ,-1);\n" + "\t\t\ta13 = safeGet(input,x+1,-1);\n" + "\t\t\ta21 = safeGet(input,x-1, 0);\n" + "\t\t\ta22 = safeGet(input,x , 0);\n" + "\t\t\ta23 = safeGet(input,x+1, 0);\n" + "\t\t\ta31 = safeGet(input,x-1, 1);\n" + "\t\t\ta32 = safeGet(input,x , 1);\n" + "\t\t\ta33 = safeGet(input,x+1, 1);\n" + "\n" + "\t\t\tvalue = 9*a22 - (a11+a12+a13+a21+a23+a31+a32+a33);\n" + "\n" + "\t\t\tif( value > maxValue )\n" + "\t\t\t\tvalue = maxValue;\n" + "\t\t\telse if( value < minValue )\n" + "\t\t\t\tvalue = minValue;\n" + "\n" + "\t\t\toutput.data[indexTop++] = " + cast + "value;\n" + "\n" + "\t\t\ta11 = safeGet(input,x-1,b-1);\n" + "\t\t\ta12 = safeGet(input,x ,b-1);\n" + "\t\t\ta13 = safeGet(input,x+1,b-1);\n" + "\t\t\ta21 = safeGet(input,x-1, b);\n" + "\t\t\ta22 = safeGet(input,x , b);\n" + "\t\t\ta23 = safeGet(input,x+1, b);\n" + "\t\t\ta31 = safeGet(input,x-1,b+1);\n" + "\t\t\ta32 = safeGet(input,x ,b+1);\n" + "\t\t\ta33 = safeGet(input,x+1,b+1);\n" + "\n" + "\t\t\tvalue = 9*a22 - (a11+a12+a13+a21+a23+a31+a32+a33);\n" + "\n" + "\t\t\tif( value > maxValue )\n" + "\t\t\t\tvalue = maxValue;\n" + "\t\t\telse if( value < minValue )\n" + "\t\t\t\tvalue = minValue;\n" + "\n" + "\t\t\toutput.data[indexBottom++] = " + cast + "value;\n" + "\t\t}\n" + "\n" + "\t\tb = input.width-1;\n" + "\t\tint indexLeft = input.startIndex + input.stride;\n" + "\t\tint indexRight = input.startIndex + input.stride + b;\n" + "\n" + "\t\tfor( int y = 1; y < input.height-1; y++ ) {\n" + "\t\t\ta11 = safeGet(input,-1,y-1);\n" + "\t\t\ta12 = safeGet(input, 0,y-1);\n" + "\t\t\ta13 = safeGet(input,+1,y-1);\n" + "\t\t\ta21 = safeGet(input,-1, y );\n" + "\t\t\ta22 = safeGet(input, 0, y );\n" + "\t\t\ta23 = safeGet(input,+1, y );\n" + "\t\t\ta31 = safeGet(input,-1,y+1);\n" + "\t\t\ta32 = safeGet(input, 0,y+1);\n" + "\t\t\ta33 = safeGet(input,+1,y+1);\n" + "\n" + "\t\t\tvalue = 9*a22 - (a11+a12+a13+a21+a23+a31+a32+a33);\n" + "\n" + "\t\t\tif( value > maxValue )\n" + "\t\t\t\tvalue = maxValue;\n" + "\t\t\telse if( value < minValue )\n" + "\t\t\t\tvalue = minValue;\n" + "\n" + "\t\t\toutput.data[indexLeft] = " + cast + "value;\n" + "\n" + "\t\t\ta11 = safeGet(input,b-1,y-1);\n" + "\t\t\ta12 = safeGet(input, b ,y-1);\n" + "\t\t\ta13 = safeGet(input,b+1,y-1);\n" + "\t\t\ta21 = safeGet(input,b-1, y );\n" + "\t\t\ta22 = safeGet(input, b , y );\n" + "\t\t\ta23 = safeGet(input,b+1, y );\n" + "\t\t\ta31 = safeGet(input,b-1,y+1);\n" + "\t\t\ta32 = safeGet(input, b ,y+1);\n" + "\t\t\ta33 = safeGet(input,b+1,y+1);\n" + "\n" + "\t\t\tvalue = 9*a22 - (a11+a12+a13+a21+a23+a31+a32+a33);\n" + "\n" + "\t\t\tif( value > maxValue )\n" + "\t\t\t\tvalue = maxValue;\n" + "\t\t\telse if( value < minValue )\n" + "\t\t\t\tvalue = minValue;\n" + "\n" + "\t\t\toutput.data[indexRight] = " + cast + "value;\n" + "\n" + "\t\t\tindexLeft += input.stride;\n" + "\t\t\tindexRight += input.stride;\n" + "\t\t}\n" + "\t}\n\n"); }
private void sharpenBorder4(AutoTypeImage image) { String name = image.getSingleBandName(); String cast = image.getTypeCastFromSum(); String sumtype = image.getSumType(); out.print( "\tpublic static void sharpenBorder4( " + name + " input , " + name + " output , " + sumtype + " minValue , " + sumtype + " maxValue ) {\n" + "\t\t" + sumtype + " value;\n" + "\n" + "\t\tint b = input.height-1;\n" + "\n" + "\t\tint indexTop = input.startIndex;\n" + "\t\tint indexBottom = input.startIndex + b*input.stride;\n" + "\t\t\n" + "\t\tfor( int x = 0; x < input.width; x++ ) {\n" + "\t\t\tvalue = 4*safeGet(input,x,0) - (safeGet(input,x-1,0) + safeGet(input,x+1,0) + safeGet(input,x,1));\n" + "\n" + "\t\t\tif( value > maxValue )\n" + "\t\t\t\tvalue = maxValue;\n" + "\t\t\telse if( value < minValue )\n" + "\t\t\t\tvalue = minValue;\n" + "\n" + "\t\t\toutput.data[indexTop++] = " + cast + "value;\n" + "\n" + "\t\t\tvalue = 4*safeGet(input,x,b) - (safeGet(input,x-1,b) + safeGet(input,x+1,b) + safeGet(input,x,b-1));\n" + "\n" + "\t\t\tif( value > maxValue )\n" + "\t\t\t\tvalue = maxValue;\n" + "\t\t\telse if( value < minValue )\n" + "\t\t\t\tvalue = minValue;\n" + "\n" + "\t\t\toutput.data[indexBottom++] = " + cast + "value;\n" + "\t\t}\n" + "\n" + "\t\tb = input.width-1;\n" + "\t\tint indexLeft = input.startIndex + input.stride;\n" + "\t\tint indexRight = input.startIndex + input.stride + b;\n" + "\n" + "\t\tfor( int y = 1; y < input.height-1; y++ ) {\n" + "\t\t\tvalue = 4*safeGet(input,0,y) - (safeGet(input,1,y) + safeGet(input,0,y-1) + safeGet(input,0,y+1));\n" + "\n" + "\t\t\tif( value > maxValue )\n" + "\t\t\t\tvalue = maxValue;\n" + "\t\t\telse if( value < minValue )\n" + "\t\t\t\tvalue = minValue;\n" + "\n" + "\t\t\toutput.data[indexLeft] = " + cast + "value;\n" + "\n" + "\t\t\tvalue = 4*safeGet(input,b,y) - (safeGet(input,b-1,y) + safeGet(input,b,y-1) + safeGet(input,b,y+1));\n" + "\n" + "\t\t\tif( value > maxValue )\n" + "\t\t\t\tvalue = maxValue;\n" + "\t\t\telse if( value < minValue )\n" + "\t\t\t\tvalue = minValue;\n" + "\n" + "\t\t\toutput.data[indexRight] = " + cast + "value;\n" + "\t\t\t\n" + "\t\t\tindexLeft += input.stride;\n" + "\t\t\tindexRight += input.stride;\n" + "\t\t}\n" + "\t}\n\n"); }