Grey Slicing Image Function

7 views (last 30 days)
Darrick
Darrick on 20 Nov 2012
I am trying to create a function to grey slice images using this piecewise function given by my professor:
I am running into some issues right now with setting the intensity values.
function outImage = baker10(inImage, intensities)
% convert input image to grayscale
grayImage = colorToGray(inImage);
% obtain the image size
[M, N, P] = size(grayImage);
% convert image to type double for MATLAB operations
tempim = double(inimage);
% create space for the grayscale image
outImage = zeros(M,N,3);
intensities[
% the image is converted to gray-scale by making setting RGB equal
% to the intensity of the pixel
for m = 1 : 1 : M
for n = 1 : 1 : N
for p = 1 : 1 : P
if tempim(m,n,p) < intesities(m)
outImage(m,n,p) = 0;
elseif tempim(m,n,p) >= intensities(m) && tempim(m,n,p)...
<= intensities(n);
outImage(m,n,p) = intensities(m,n,p);
else tempim(m,n,p) > intensities(n)
outImage(m,n,p) = 0;
end
end
end
% convert image back to type uint8
outImage = uint8(outImage);
outImage = outImage * 255;
end

Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!