Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

How can i extract the component H of only the region of interest?

Asked by Tomas on 12 Nov 2012

Hello

To calculate the difference between the value h of an image and values from tab, I used these lines.

h=HSV(:,:,1);
d = abs(h - tab(i,1));

Now how can i extract the H of only the region of interest because I want to calculate the difference between the value h of only the region of interest of the image and the values from tab. knowing that bw is the binairy mask of the segmented image. thanks

0 Comments

Tomas

1 Answer

Answer by Image Analyst on 13 Nov 2012

You can do this

maskedDifferences = d(bw);

5 Comments

Image Analyst on 14 Nov 2012

Use the debugger. Set a breakpoint there and see what bw is. You can type bw on the command line, you can type class(bw) or whos bw on the command line. You can look in the workspace panel, you can hover the cursor over bw in the editor window. You can click in bw and type control-D. You can double click bw in the workspace panel to bring it up in the variable editor. There are so many ways to figure out what bw is if you know how to debug programs.

You said "bw is the binairy mask of the segmented image" but apparently that is not true. bw is not a logical/binary image, so you need to find out what it is. How did you create it?

Tomas on 14 Nov 2012

using whos bw, I get

    Name        Size               Bytes  Class     Attributes
    bw         498x750            2988000  double

To get this image, I used

bw=zeros(L,C);
if (some instructions)
   bw(i,j)=1;
Image Analyst on 15 Nov 2012
bw = logical(bw);
Image Analyst

Contact us