This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
cindrella cradford
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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){}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic