Borrar filtros
Borrar filtros

How can I pick all RGB values inside a region of interest?

1 visualización (últimos 30 días)
Tweety
Tweety el 8 de Dic. de 2015
Comentada: Image Analyst el 23 de Sept. de 2018
I define the region of interest by h = imfreehand. After that I need to pick all the RGB values inside the specified region.

Respuesta aceptada

Arnab Sen
Arnab Sen el 28 de Dic. de 2015
From your description my understanding is you would like to select a region of your interest and then to get the pixel value of all the points bounded by the region. You can create a binary mask for the bounded region of interest and then get all the coordinates. Finally we can get all the pixel of that region using the function 'impixel'.
The following code illustrates how to achieve this:
>> i=imshow('sampleimg.png')
>> h=imfreehand(gca)
>> roi=createMask(h);
>> [row,col]=find(roi);
>> i1=imread('sampleimg.png');
>> RGBpixels=impixel(i1,col,row)
For more details the functions 'createMask' and 'impixel', refer to the following links:
  4 comentarios
Zahara
Zahara el 15 de Feb. de 2016
Hi there,
I have a similar problem. I have been trying to sort this out for a few days... I need help :). I have an image, I created a region of interest based on xp=[x1 x2 x3 x4] and yp=[y1 y2 y3 y4]. The region of interest is kind of curvy, as it follows a pattern.
I'd like to get the information from inside this region of interest. For the sake of automation, I wouldn't like to use imfreehand. I have to do this for many regions on interest. Instead, I calculated the line which join the points as a squarish region of interest. Fed the point, which belong to each line as col and row values for impixel.When I compare what I would get using imfreehand and my method...No luck!
I've tried imcrop also but because the region of interest is angled and a bit curvy, it would do the trick.
Any advice to point me on the right direction would be appreciate it.
Thanks a lot!
Z
Image Analyst
Image Analyst el 23 de Sept. de 2018
Get the values from your image with a mask:
[rows, columns] = size(grayImage);
mask = poly2mask(x, y, rows, columns);
imageValues = grayImage(mask);

Iniciar sesión para comentar.

Más respuestas (1)

Nuttawut Yeenang
Nuttawut Yeenang el 23 de Sept. de 2018
Thank you

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by