Removing narrow blobs from an image...please help!
Hi,
I need to write something in Java that can remove long narrow blobs
in an image - say for a black blobs on a mainly white image. Problem
is though - I don't know how to do it. Can you help me please?
Here is what I have so far. I would greatly appreciate any suggestions/
comments/code-samples that you may be able to offer.
Cheers,
Colm
***** CODE AS FOLLOWS ******
// Remove long narrow blobs from an image. Not nice round
blobs - just long thin ones.
private static ImageProcessor RemoveLongNarrowBlobs
(ImageProcessor inputImage, int someVariables)
{
// 1. Make a copy of the original image - this is where the
new image will go
ImageProcessor outputImage = new ShortProcessor
(inputImage.getWidth(), inputImage.getHeight());
outputImage = outputImage.convertToRGB();
// 2. Member variables
int origPixel;
int pixAfterWhiteMap;
// 3. Cycle through the dimentsion of the original image
and do the business
for (int i = 0; i < inputImage.getWidth(); i++)
{
for (int j = 0; j < inputImage.getHeight(); j++)
{
// For each pixel get a white map
origPixel = inputImage.get(i,j);
pixAfterWhiteMap = origPixel & 0xFFFFFF; //white
if(pixAfterWhiteMap > 0) //not black
{
}
}//j
}//i
return outputImage;
}