简体   繁体   中英

Matlab : ROI substraction

I'm learning about statistical feature of an image.A quote that I'm reading is

For the first method which is statistical features of texture, after the image is loaded, it is converted to gray scale image. Then the background is subtracted from the original image. This is done by subtract the any blue intensity pixels for the image. Finally, the ROI is obtained by finding the pixels which are not zero value.

The implementation :

% PREPROCESSING segments the Region of Interest (ROI) for
% statistical features extraction.
% Convert RGB image to grayscale image
g=rgb2gray(I);
% Obtain blue layer from original image
b=I(:,:,3);
% Subtract blue background from grayscale image
r=g-b;
% Find the ROI by finding non-zero pixels.
x=find(r~=0);
f=g(x);

My interpretation :

The purpose of substracting the blue channel here is related to the fact that the ROI is non blue background? Like :

在此处输入图片说明

But in the real world imaging like for example an object but surrounded with more than one colors? What is the best way to extract ROI in that case? like for example (assuming only 2 colors on all parts of the bird which are green and black, & geometri shaped is ignored):

在此处输入图片说明

what would I do in that case? Also the picture will be transformed to gray scale right? while there's a black part of the ROI (bird) itself.

I mean in the bird case how can I extract only green & black parts? and remove the rest colors (which are considered as background ) of it?

Background removal in an image is a large and potentielly complicated subject in a general case but what I understand is that you want to take advantage of a color information that you already have about your background (correct me if I'm wrong).

If you know the colour to remove, you can for instance:

  • switch from RGB to Lab color space ( Wiki link ).
  • after converting your image, compute the Euclidean from the background color (say orange), to all the pixels in your image
  • define a threshold under which the pixels are background

In other words, if coordinates of a pixel in Lab are close to orange coordinates in Lab , this pixel is background. The advantage of using Lab is that Euclidean distance between points relates to human perception of colours.

I think this should work, please give it a shot or let me know if I misunderstood the question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM