Matlab Code – Digital Image Processing

To show image from desktop folder to matlab image viewer

I=imread('C:\Users\Daffodil\Desktop\imread\zaki.jpg');
image(I)

then to convert YIQ value we need to write this line

YIQ=rgb2ntsc(I);

and for converting rgb to hsv we need tghis line

HSV=rgb2hsv(I);

 

To make it grayscale

B=rgb2gray(I);
imshow(B);

For showing the size:

size(I); //outpput will be 300x205x3 height x width x byte ; it's for color image
size(B); //output will be 300x205 height x width ; it's for grayscale image

For plotting in a matrix it follow subplot(m,n,p), imshow(X); format of 2×2 matrix 1 no. coloumn where p=1 and if p=2 then it will be plot in 2 no column

subplot(2,2,1), imshow(I);
subplot(2,2,2), imshow(B);

subplot

For finding edges from grayscale image and plot in coloumn 3 using canny method

C=edge(B,'canny');
subplot(2,2,3), imshow(C);

 

For finding edges from grayscale image and plot in coloumn 4 using sobel method

D=edge(B,'sobel');
subplot(2,2,4), imshow(D);

Example:

subplot-4

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *