0% found this document useful (0 votes)
14 views53 pages

Dip University Question Paper Problems

Dip

Uploaded by

R INI BHANDARI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views53 pages

Dip University Question Paper Problems

Dip

Uploaded by

R INI BHANDARI
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 53

Topic: Introduction about MATLAB tool Hands on experience

1. Read and Display an Image

Clear, close all


I=imread('figure1.jpg');
imshow(I)
2. Check the Image in Memory

Whos
3. Write the Image

imwrite (I2, 'figure2.jpg');


4. Check the Contents of the Newly Written File

imfinfo('figure2.jpg')

5. Colour conversion

RGB_label = rgb2gray('figure2.jpg');
imshow(RGB_label);

6. The Color Planes of an RGB Image

R=RGB(:,:,1);
G=RGB(:,:,2);
B=RGB(:,:,3);
figure, imshow(R)
figure, imshow(G)
figure, imshow(B)

7. Converting Graphics File Formats


bitmap = imread('mybitmap.bmp','bmp');
imwrite(bitmap,'mybitmap.png','png')

8. Adding Images

I = imread('figure1.jpg');
J = imread(''figure2.jpg');
K = imadd(I,J);
imshow(K)

9. Addition to brighten an image by adding a constant value

RGB = imread(' figure1.jpg ');


RGB2 = imadd(RGB,50);
subplot(1,2,1); imshow(RGB);
subplot(1,2,2); imshow(RGB2)

10. Multiplying Images

I = imread('rice.tif');
J = immultiply(I,1.2);
imshow(I);
figure, imshow(J)

11. Average of two images

I = imread('rice.tif');
I2 = imread('cameraman.tif');
K = imdivide(imadd(I,I2), 2); % not recommended
figure, imshow(K)

12. Adding a Colorbar

I = imread('saturn.tif');
imshow(I2,[]), colorbar

13. Perform Histogram Equalization

I2 = histeq(I); % Equalize I and output in new array I2


figure, imshow(I2) % Display the new equalized image I2
figure, imhist(I2) % Show the histogram for the new image I2.

14. Apply Thresholding to the Image

level = graythresh(I3);
bw = im2bw(I3,level);
figure, imshow(bw)

15. Determine the Number of Objects in the Image

[labeled,numObjects] = bwlabel(bw,4);% Label components

16. Displaying Each Image in a Separate Figure

[X1,map1]=imread(‘figure1.jpg’);
[X2,map2]=imread(‘figure2.jpg’);
imshow(X1,map1),figure,imshow(X2,map2);
17. Displaying Multiple Images in the Same Figure

[X1,map1]=imread(‘figure1.jpg’);
[X2,map2]=imread(figure2.jpg’);
subplot(1,2,1), imshow(X1,map2)
subplot(1,2,2), imshow(X2,map2)

18. Zooming In or Out from the Command Line

zoom on
zoom out
zoom off

19. Image Resizing

I = imread(‘figure1.jpg’);
J = imresize(I,1.25);
imshow(I)
figure, imshow(J)

20. Specifying the Size of the Output Image

Y = imresize(X,[100 150])

21. Image Rotation

I = imread(‘figure1.jpg’);
J = imrotate(I,35,'bilinear');
imshow(I)
figure, imshow(J)

22. Image Cropping

imshow (‘figure1.jpg’)
I = imcrop;
imshow(I)

23. Edge Detection

I = imread(‘figure1.jpg’);
BW1 = edge(I,'sobel');
BW2 = edge(I,'canny');
imshow(BW1)

24. Dilating an Image

SE = strel('square',3)
BW2 = imdilate(BW,SE)
25. Eroding an Image

BW1 = imread(‘figure1.jpg’);
SE = strel('arbitrary’,eye(5));
BW2 = imerode(BW1,SE);
imshow(BW1)
figure, imshow(BW2)

26. Combining Dilation and Erosion

To morphologically open the image, perform these steps:


1 Create a structuring element.
SE = strel('rectangle’,[40 30]);
2 Erode the image with the structuring element.
BW1 = imread(‘figure1.jpg’);
BW2 = imerode(BW1,SE);
imshow(BW2)

27. This removes all of the lines, but also shrinks the rectangles.

BW3 = imdilate(BW2,SE);
imshow(BW3)

28. Skeletonization

BW1 = imread(‘figure1.jpg’);
BW2 = bwmorph(BW1,'skel',Inf);
imshow(BW1)
figure, imshow(BW2)

29. Perimeter Determination

BW1 = imread(‘figure1.jpg’);
BW2 = bwperim(BW1);
imshow(BW1)
figure, imshow(BW2)

You might also like