Experiment No. 8: MATLAB Program
Experiment No. 8: MATLAB Program
8
Objective: Write a program to filter Colour from an image in MATLAB. Software Used: MATLAB R2010a About the Experiment:
In this experiment we will learn how to filter color in Matlab. Matlab provide very good Image processing tool box with many ready made functions. This experiment illustrated a very basic method to filter color in Matlab. The concept is- in the 3D matrix of RGB color space, if the value at a particular pixel have more value in Red space than blue or Green, and if it is within a tolerance value then consider that pixel Red.
MATLAB Program:
I=imread('C:\Users\Public\Pictures\Sample Pictures\inarc.jpg'); subplot(2,2,1);imshow(I);title('original image'); S=size(I); for i=1:S(1) for j=1:S(2) I(i,j,2)=0; end; end; subplot(2,2,2);imshow(I);title('processed image1'); for i=1:S(1) for j=1:S(2) I(i,j,2)=0; I(i,j,3)=0; end; end; subplot(2,2,3);imshow(I);title('processed image2'); for i=1:S(1) for j=1:S(2) I(i,j,2)=0; I(i,j,3)=0; I(i,j,1)=0; end; end; subplot(2,2,4);imshow(I);title('processed image3');
Result: