Forums Register Login

to scan a image verically in oder to create its vertical histogram

+Pie Number of slices to send: Send
hello frnds,
i have a image whose vertical histogram i hv to obtain in oder to do some other functioning but pixelgrabber scans the image horizontally by taking scan line width as an argument........i.e it scans the all the columns of first row of image and then it jumps to next row.......what i want is it should scan first all rows of first column and then all rows of second column and so on.
i am giving my code of horizontal histogram (which is working correctly)
and my code of vertical histogram.....
please help me in doing the task
"FOR CALCULATING HORIZONTAL HISTOGRAM"
w= width;
h = height;
linepixels = new int [w*h] ;
linepix = new int [h][w] ;
hHisto = new int[h] ;
PixelGrabber pg = new PixelGrabber (img,0,0,w,h,linepixels,0,w);
try
{ pg.grabPixels();
}
catch(InterruptedException ee){ }

for (int t = 0 ;t <h ; t++)
hHisto[t] = 0;
try{
for( int i=0;i<w*h;i++)
{ int p= linepixels[i] ;
int r = 0xff & (p>>16) ;
int g = 0xff & (p>>8);
int b = 0xff & (p);

if(r>=127 && g>=127&& b>=127)
linepixels[i]=1;
else
linepixels[i]=0;

}
}
catch(ArrayIndexOutOfBoundsException out){}
int j= 0;
try{
for(int m=0; m<h;m++)
{ for(int n=0;n<w;n++)
{
linepix[m][n] = linepixels[j] ;
if (linepix[m][n]==0)
{

hHisto[m]=hHisto[m] + 1 ;

}

j++ ;
}


}

}
catch(ArrayIndexOutOfBoundsException out){}



"FOR CACULATING VERTICAL HISTOGRAM"

wordpixels = new int [hh*w] ;
wordpix = new int [w][hh] ;
subvHisto = new int[w] ;
PixelGrabber pg = new PixelGrabber (img,0,harr[jj],w,hh,wordpixels,0,w);
jj=jj+2;
try
{ pg.grabPixels();
}
catch(InterruptedException ee){ }

for (int t = 0 ;t <w ; t++)
subvHisto[t] = 0;
try{
for( int i=0;i<w*hh;i++)
{ int p= wordpixels[i] ;
int r = 0xff & (p>>16) ;
int g = 0xff & (p>>8);
int b = 0xff & (p);

if(r>=127 && g>=127&& b>=127)
wordpixels[i]=1;
else
wordpixels[i]=0;

}
}
catch(ArrayIndexOutOfBoundsException out){}
int j= 0;
try{
for(int m=0; m<w;m++)
{ for(int n=0;n<hh;n++)
{
wordpix[m][n] =wordpixels[j] ;
if (wordpix[m][n]==0)
{

subvHisto[m]=subvHisto[m] + 1 ;

}

j++ ;
}


}

}
catch(ArrayIndexOutOfBoundsException out){}
I am going to test your electrical conductivity with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1313 times.
Similar Threads
HTTP request 'GET' example
single dimension array to multi dimension
How to divide an array
getting problem in creating an image from int array
How do i find out what color a certain pixel is?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 08:00:23.