How to extract objects to a region of interest in Matlab

I am interested in retrieving objects within an area.

For instance,

Figure 1 showed the intensity profile of my laser profile. By laser intensity, I divide the profile into 2 region of interest (ROI1 and ROI2).

Figure 2 shows the overlap of my result of the expression of positive responses and the laser intensity profile. The positive response data file consists of x and y coordinates. As you can see, the results are scattered from the image of the laser profile.

Here is what I want to do, I want to remove the spots in ROI2 and reset everything else, as shown in Fig. 3. How do I do this? In particular, how can I determine the irregular shape ROI2 in matlab and extract the coordinates of the positive response data. Thanks for the help.

enter image description here

+4
source share
3 answers

As eykanal says, you can use the impoly function to create whatever ROI you want in your image. A general solution for retrieving coordinators is to create the required ROI and use find to retrieve the coordinates and some setup operation to remove the unwanted points. Like this:

imshow(image) h = impoly() ; %# draw ROI1 ROI1 = createMask(h); %# create binary mask of ROI1 h2 = impoly(); %# draw dummy_ROI consisting of ROI1+ROI2 dummy_ROI = createMask(h2); %# create binary mask ROI2 = dummy_ROI-ROI1; %# create ROI2 p = find(ROI2); %# find all coordinates of ROI2 points = intersect(ind,p); %# find all points with linear index ind that are %# part of ROI2 
+5
source

I think this problem is simpler than you think, provided that you always segment the image along (what it seems) contour lines. You want to select all the points that have a value greater than the contour line 1, and less than the contour line 2. I'm not sure how you specified the contour lines, but the selection command should be simple:

 #% let laserData be the image data (it looks like it should #% be 512x256, so I'll assume that) highBound = mean(contour1points); lowBound = mean(contour2points); selectedData = laserData(laserData > lowBound & laserData < highBound); 

If, apparently, you just set the contours based on the value, then mean(contour1points) can be replaced with a custom value, using the function to get the pixel value under the cursor, which I can probably recall now. If you want to define a polygon, check the impoly function .

+3
source

I don’t know what representation you use for your ROIs, but I would suggest several methods:

  • If your ROI is an ellipse and you know its equation, simply apply it to the coordinates of the results. Use the sign to decide whether it is inside or not.

  • If your ROI is a polygon, you can use the inpolygon function

  • You can display ROI in black and white and easily test hit / miss.

Please provide more details on the presentation of ROI.

0
source

All Articles