0

I'm writing a code that allows the user to choose some regions in an image and then I shall show the image with the regions in gray (different gray level for each different region). The user doesn't have to choose every region in the image, so if the image has 5 regions he could choose just 1 or 2,3... The exact procedure is this: The user chooses 2 pixels for every region he wants, I create a subimage with this bounding box that only includes pixels of the region. Then I calculate the first order moments (mean, variance, skewness and kurtosis) of the subimage. The only step left is to find all the pixels in the image that pertain to that region applying neighbourhood operations.

I have a value of each order moment for each region, but the range of values for these subregions I calculate to specify if a pixel pertains to the region may vary. So the problem I have is that I don't know how to create a threshold to specify if a pixel is included into a region or not.

Maybe there's some function that allows you to input a value and tells you which is the closer value from a range of values?

user2952272
  • 361
  • 3
  • 18

1 Answers1

1

If you calculate the mean and std of the region in the bounding box it'll give a lot of useful information. Go ahead to a unsegmented pixel, check its value and see if it belongs to one of the segmented areas by :

[not a code but just a logic]

if (currentPixel <= (regionAvg + regionSTD )|| currentPixel >= (regionAvg - regionSTD) than add currentPixel to region.

Does it make sense?

Lior Magen
  • 1,533
  • 2
  • 15
  • 33