MATLAB: Median gray level value image analysisimage processingmammogrammedianpixels Hi there, How can I find the median gray level of non-zero valued pixels in an image? I am working on mammograms that have lot of zero valued pixels, but it dosent matter. Thanks Best Answer Hi Faraz, you can simply make a mask of the pixels you don't want to include, then take the median of all the others:Im = randi(10,512,512) - 1; % Sample image with some 0szeroMask = Im==0; % Mask of 0smedValue = median(Im(~zeroMask)) % Median of the restOr, in one command:medValue = median(Im(Im>0)); Related SolutionsMATLAB: Vector median filter for 1D median filtering, Matlab has command medfilt1Eq:medfilt1([4 3 5 2 8 9 1],3)ans = 3 4 3 5 8 8 1 MATLAB: Image thresholding using min and max pixel intensity values Try this:mask = grayImage >= 165 & grayImage <= 166 % Mask of only pixels with GLs of 165 and 166grayImage(~mask) = 0; % blacken outside the mask. Related Question
Best Answer