wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes to scan a image verically in oder to create its vertical histogram Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "to scan a image verically in oder to create its vertical histogram " Watch "to scan a image verically in oder to create its vertical histogram " New topic
Author

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

cindrella cradford
Greenhorn

Joined: Jun 20, 2006
Posts: 3
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 agree. Here's the link: http://aspose.com/file-tools
 
subject: to scan a image verically in oder to create its vertical histogram
 
Similar Threads
How do i find out what color a certain pixel is?
How to divide an array
HTTP request 'GET' example
getting problem in creating an image from int array
single dimension array to multi dimension