How can I pick all RGB values inside a region of interest?
6 views (last 30 days)
Show older comments
I define the region of interest by h = imfreehand. After that I need to pick all the RGB values inside the specified region.
0 Comments
Accepted Answer
Arnab Sen
on 28 Dec 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 Comments
Image Analyst
on 23 Sep 2018
Get the values from your image with a mask:
[rows, columns] = size(grayImage);
mask = poly2mask(x, y, rows, columns);
imageValues = grayImage(mask);
More Answers (1)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!