Code covered by the BSD License  

Highlights from
Image Enhancement

from Image Enhancement by Madhu S. Nair
Image Enhancement Range Compression Skewing slicing low pass high pass filter threshold digital nega

slicing1(x)
%Question No:11
%IMAGE SLICING WITH BACKGROUND

function slicing1(x)
f=imread(x);
L=max(max(f));
a=input('Enter the lower range, a = ');
b=input('Enter the higher range, b = ');
[M,N]=size(f);
        for x = 1:M
            for y = 1:N
                if(f(x,y)>=a & f(x,y)<=b)
                    g(x,y)=L;
                else
                    g(x,y)=f(x,y);
                end
            end
        end
imshow(f), figure, imshow(g);
end

Contact us at files@mathworks.com