I want to separate a range of pixels from the whole image.How shall i extract the values
3 views (last 30 days)
Show older comments
now the matrix is of a gray scale image 512x512.
I want to separate the values like 134 132 so on upt 169. and I want the extra pixels to be deleted. Is it possible.as I want to create a mask out of the above intensity values
3 Comments
Answers (1)
Image Analyst
on 3 Feb 2018
Explain EXACTLY what "removed" or "deleted" means to you, keeping in mind that an image must remain rectangular. You can set the values out of that range to some other value, like 0 or 255 or nan or something, like this:
mask = grayImage >= 132 & grayImage <= 169;
grayImage(~mask) = 0; % Set outside mask equal to 0.
grayImage will still be a 2-D image with the pixels outside the mask STILL THERE, just black (0).
Alternatively however, you can extract all the other values into a 1-D list if you want.
listOfValuesInMask = grayImage(mask); % A 1-D vector.
listOfValuesInMask is now a 1-D list of all pixel value in the mask in column major order (taken from mask top to bottom, left to right).
2 Comments
Image Analyst
on 5 Feb 2018
I don't know how to do that off the top of my head. Anyway, it's be more than a 5 minute effort. I suggest you look for algorithms here: http://www.visionbib.com/bibliography/contentsmedical.html#Medical%20Applications,%20CAT,%20MRI,%20Ultrasound,%20Heart%20Models,%20Brain%20Models
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!