Write a MATLAB code for comparative analysis of different gray level resolution of image



CODE:
clear all;
close all;
clc;
a=imread('cameraman.tif');
b1=[];
b2=[];


for m=1:256
    for n=1:256
        if a(m,n)>100 && a(m,n)<199
            b1(m,n)=a(m,n);
        else
            b1(m,n)=0;
        end
       
    end
end

for m=1:256
    for n=1:256
        if a(m,n)>100 && a(m,n)<199
            b2(m,n)=0;
        else
            b2(m,n)=a(m,n);
        end
       
    end
end


subplot(1,3,1);
imshow(a);
title('image of cameramen','color','r'); 

subplot(1,3,2);
imshow(b1);
title('image-1','color','r'); 
subplot(1,3,3);
imshow(b2);
title('image-2','color','r'); 


OUTPUT: