1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
nWidth = countBloc("height");
nHeight = countBloc("width");
getRGBValue(nWidth, nHeight);
nBlocs = nWidth * nHeight;
print("nBlocsLargeur = " + nWidth + " nBlocsHauteur = " + nHeight + " nBlocsTotal = " + nBlocs);
function countBloc(dimension){
value = getPixel(0,0);
if (bitDepth==24) {
initRed = 0;
initGreen = 0;
initBlue = 0;
}
nBloc = 0;
if(dimension == "height")dim = getHeight();
if(dimension == "width")dim = getWidth();
for(i=0; i<dim; i++){
if(dimension == "height")value = getPixel(0,i);
if(dimension == "width")value = getPixel(i,0);
if (bitDepth==24) {
red = (value>>16)&0xff;
green = (value>>8)&0xff;
blue = value&0xff;
}
if((initRed!=red)|(initGreen!=green)|(initBlue!=blue)){
nBloc++;
initRed = red;
initGreen = green;
initBlue = blue;
}
}
return nBloc;
}
function getRGBValue(nWidth, nHeight){
//taille en pixel de un carré
widthBloc = getWidth()/nWidth;
heightBloc = getHeight()/nHeight;
for(x=0; x<nWidth; x++){
for(y=0; y<nHeight; y++){
makePoint(widthBloc/2 + x*widthBloc, heightBloc/2 + y*heightBloc);
RGBValue = getPixel(widthBloc/2 + x*widthBloc, heightBloc/2 + y*heightBloc);
print(widthBloc/2 + x*widthBloc);
red = (RGBValue>>16)&0xff;
green = (RGBValue>>8)&0xff;
blue = RGBValue&0xff;
data = "R:" + red + " G:" + green + " B:" + blue;
column = "X "+ x;
setResult(column, y, data);
}
}
} |
Partager