I want to separate a range of pixels from the whole image.How shall i extract the values

3 views (last 30 days)
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
ayesha
ayesha on 3 Feb 2018
Actually i want to extract the region of interest having the intensity values 132,168,134.. the other values displayed in the matrix like 9, 256 etc are to be removed

Sign in to comment.

Answers (1)

Image Analyst
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
ayesha
ayesha on 5 Feb 2018
thank you for the guidance. It taught me how to use masking. My objective is to extract liver out of the CT scan and suppress ALL OTHER ORGANS. I am attaching the picture. please suggest shall I apply any pre processing technique for a good mask creation.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!