Grey Slicing Image Function

7 次查看(过去 30 天)
Darrick
Darrick 2012-11-20
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

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Processing Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by