2

I'm pretty new to matlab, but heres the situation. I have a satellite image of an ocean, with a bit of land and some boats in it. Using thresholding to make a binary mask and bwlabel I have managed to create a set of labels which match up to the boats on the water. Here is a superimposed image of the labels over the boats (and land) so you can see what I mean:

enter image description here

As you can see from the image, the labels encompass the boats as well as some dimmer sidelobes either side of them. I need to find a way to create a new set of labels which cover only the boats and not the sidelobes. I can't just use a brighter threshold, as I have lots of images with boats of varying brightness, some of which will be dimmer than the side lobes of other boats.

So I guess what I'm asking is, is there a way to extract the coloured sections from this image, analyse them further (by thresholding the individual segments, or using histograms or whatever) to create a new set of labels containing only the boats, but also keep the locations of these new labels with respect to the original image intact so I can superimpose them back onto the original image again? If so, how?

Thanks!

Jacob
  • 34,255
  • 14
  • 110
  • 165

2 Answers2

2

Several questions here.

1. Is is there a way to extract the colored sections from this image?

Yes.

Let the label image you obtained from bwlabel be L and the original image be I. Then, S = regionprops(L,'BoundingBox'); will give you the bounding box associated with each region in L. Use I2 = imcrop(I,S(2).BoundingBox); to extract the region in S(2). You'll have to check whether S(2) corresponds to the label 2 in L (if not, fixing that is trivial).

2. Analyse them further (by thresholding the individual segments, or using histograms or whatever) to create a new set of labels containing only the boats.

Not so straightforward. This is highly dependent on your images. You can play with MATLAB's default thresholding functions to make it work. Assume that you obtain binary masks for each cropped image (e.g. IB1).

3. Also keep the locations of these new labels with respect to the original image intact so I can superimpose them back onto the original image again?

Yes. Since you have the set of bounding boxes S just replace the new mask in L.

L(round(S(1).BoundingBox(2):S(1).BoundingBox(2)+S(1).BoundingBox(4)),... round(S(1).BoundingBox(1):S(1).BoundingBox(1)+S(1).BoundingBox(3))) = IB1;

where I1 is the improved mask. Don't forget to set all non-zero values in your mask to the label index when assigning to L.

For more on why round is used, look here.

Community
  • 1
  • 1
Jacob
  • 34,255
  • 14
  • 110
  • 165
0

Could you multiply the old image by the labelled areas (or im_label~=0 as they will have different label values) to remove the non-relevant information, and then process the image again using the "whatever" method after the background is removed?

Hugh Nolan
  • 2,508
  • 13
  • 15