how do I threshold pixels in an image and convert the background pixels to nothing instead of zero?
36 views (last 30 days)
I want to create a threshold for the pixels then set them to nothing.
here is what I have thus far:
%set a pixel threshold cutoff (60 is my threshold) - minimize background by choosing a
%value cutoff, such that every pixel less than that value is considered one class,
%while every pixel greater than that value is considered the other class.
I = imread('.tiff');
level = graythresh(I)
BW = imbinarize(I,level);
Display the original image next to the binary image.
Can this work for a RGB image?
Now I want to convert everything not of interest i.e. the background and pixels not of interest to NAN
%convert the intensity values of the background to "nothing"
% rather than to 0 and keeps the other values
After reading my image I, If i want to make all the black pixels [0 60] to NaN:
I(I>=0 & I<= 60) = NaN
Thank you so much, I am stuck at this stage and cannot move. Please help.
Image Analyst on 22 Jul 2022
What you gave will work for a color image and an image of any dimensions. However, there is no need to do what you asked. It's possible to do anything you want with just the regular binary image.