In: Computer Science
Create two new images by applying a threshold first to various colors in the image. In practice, applying a threshold means that you zero out (set to zero) any value above or below a specified limit. For the first image (im1mod1), zero out all pixels that are below the value 128. For the second image (im1mod2), zero out all red pixels entirely, zero out all green pixels ABOVE 128, and zero out all blue pixels BELOW 128. Use the command image(image_variable) to display each image. In MatLab please.
clc; clear all;
im1mod1 = imread("lena_color.tiff");
figure()
image(im1mod1) %show the input image(Figure1)
for r=1:size(im1mod1,1)
for g=1:size(im1mod1,2)
for b=1:size(im1mod1,3)
if(im1mod1(r,g,b) < 128)
im1mod1(r,g,b) = 0;
end
end
end
end
figure() %show the modified image
image(im1mod1)
im1mod2 = imread("lena_color.tiff");
for r=1:size(im1mod2,1)
for g=1:size(im1mod2,2)
im1mod2(r,g,1) = 0;
if(im1mod2(r,g,2) > 128)
im1mod2(r,g,2) = 0;
if(im1mod2(r,g,3) < 128)
im1mod2(r,g,3) = 0;
end
end
end
end
figure()
image(im1mod2)
input image
im1mod1 image
im1mod2 image