Lab 4 machine vision lab reports experiment PDF

Title Lab 4 machine vision lab reports experiment
Author Surfraz Bin Amir
Course Machine Design
Institution COMSATS University Islamabad
Pages 6
File Size 753.5 KB
File Type PDF
Total Downloads 52
Total Views 155

Summary

machine vision lab reports for machine vision applications and industrial mchine learning processes............................. machine vision lab reports...


Description

MCT-453: Machine Vision Implementation of point/pixel operations in MATLAB Lab Session 4: Objective: This lab session will be about implementing intensity transformation pixel/point based such as image negative, image scaling, power law and intensity level slicing.

Intensity Transformation in Spatial Domain: Image Negative: Image negative can be obtained by inverting intensity values.

g(x,y) = (L-1) – f(x,y) Here, L is the intensity levels (255 etc)  For Binary Image, perform image negative and show the results

Code: clc; clear all; close all bw=imread('text.png'); bw2=1-bw %%same as imcomplement command imshowpair(bw,bw2,'montage') % imshowpair show two images side by side

Fig4.1: Text Image(Left) & it’s Inverted Image (Right)  For gray scale Image, perform image negative and show the results

Code: bw=imread('cameraman.tif'); bw2=254-bw %%same as imcomplement command imshowpair(bw,bw2,'montage') title('Cameraman')

Fig4.2: Cameraman Image (Left) & it’s Inverted Image (Right) Alteratively, imcomplement( image ) can perform image negative with built in matlab function.

Lab Activity 01: 1. From internet, search out two x-ray images and apply image negative for enhancements purpose Code: bw=imread('xray.jpg'); bw2=254-bw %%same as imcomplement command imshowpair(bw,bw2,'montage')

Fig4.3: Xray Image (Left) & it’s Inverted Image (Right)

Fig4.4: Xray Image (Left) & it’s Inverted Image (Right) 2. Search out a binary images from internet, and apply image negative, Code: bw=imread('bin.png'); bw2=1-bw %%same as imcomplement command imshowpair(bw,bw2,'montage') % imshowpair show two images side by side

Fig4.5: Binary Image (Left) & it’s Inverted Image (Right)

Image Intensity Scaling: g(x,y) = a. f(x,y) Steps: 1. 2. 3. 4. 5. 6.

Read any image with overall poor illumination such as office_2.jpg Convert image to grayscale (rgb2gray) Map values from 0-255 to 0-1 Apply scaling formula, the value of 1 < a > 5 Do reverse mapping from 0-1 to 0-255 Display both image and observe effects of the value of a and stop increasing value when white details begin to lost.

Code: %% Image intensity scaling I = imread('office_2.jpg'); J = double(rgb2gray(I)); M = J/255; K = 1.5.*M; O = uint8(K*255) imshowpair(J,K, 'montage')

Fig4.6: Office Image (Left) & it’s Scaled Image (Right)

Power Law transformation: Apply power law transformation to MRI image of human spine (fractured_spine.tif).All the images to be used below can be download from the link given chapter 3 http://www.imageprocessingplace.com/DIP-3E/dip3e_book_images_downloads.htm

Fig4.7: MRI Image & it’s power law transformed image

Code: cd 'E:\Study\Semester 8\Machine Vision\LAB\LAB4\DIP3E_CH03_Original_Images' clc; clear all; close all I = imread('Fig0308(a)(fractured_spine).tif'); J = im2double(I); K = 1*(J.^0.6); %c=1 & Lemda=0.6 L = 1*(J.^0.4); %c=1 & Lemda=0.4 M = 1*(J.^0.3); %c=1 & Lemda=0.3 imshowpair(J, K, 'montage'); title('Orignal Image & Image for c=1 & Lemda=0.6 ') figure imshowpair(L, M, 'montage'); title('Image for c=1 & Lemda=0.4 & Image for c=1 & Lemda=0.3 ')

Fig4.8: MRI Image & it’s power law transformed images Apply power law transformation to aerial office image (office_2.jpg) Code: I = imread('office_2.jpg'); J1 = rgb2gray(I); J = im2double(J1); K = 2*(J.^0.6); L = 2*(J.^0.4); M = 2*(J.^0.3); imshowpair(J, K, 'montage'); title('Orignal Image figure imshowpair(L, M, 'montage'); title('Image for c=1 & Lemda=0.4

Image for c=1 & Lemda=0.6

')

Image for c=1 & Lemda=0.3 ')

Fig4.9: Office Image & it’s power law transformed images

Activity 02: Apply power law transformation to aerial satellite image (washed_out_aerial_image.tif) as shown below, display all images in a subplot image with appropriate titles and gamma values with shortest code.

Code: %% Activity2 I = imread('Fig0309(a)(washed_out_aerial_image).tif'); J = im2double(I); K = imadjust(J, [ ], [ ], 3); L = imadjust(J, [ ], [ ], 4); M = imadjust(J, [ ], [ ], 5); subplot(2,2,1); imshow(J); title('Orignal Image') subplot(2,2,2); imshow(K); title('Image for c=1 & Lemda=3') subplot(2,2,3); imshow(L); title('Image for c=1 & Lemda=4') subplot(2,2,4); imshow(M); title('Image for c=1 & Lemda=5')

Fig4.10: Satellite Image & it’s power law transformed images Alternatively; Imadjust command can be used to apply power law transformation or gamma correction. J = imadjust(i, [ ], [ ], 5);

% last argument is gamma value

Imadjust command can be used to apply image negative. J = imadjust(a,[],[1;0]);

Intensity Level Slicing: Highlighting a specific range of intensities in an image often is of interest.

Lab Activity 03: Write a m- file which takes a low contrast image as input and apply a intensitylevel slicing using transformation of Fig 3.11(a). Secondly, preserve the region of kidney and blood vessels and dark out all other regions using transformation similar of Fig3.11(b). Your function file should display original image, resultant images in one figure as above. Code: cd 'E:\Study\Semester 8\Machine Vision\LAB\LAB4\DIP3E_CH03_Original_Images' Img=imread('Fig0312(a)(kidney).tif'); a=Img; %% Slicing type a b=Img; %% Slicing type b [w h]=size(Img); for i=1:w for j=1:h if Img(i,j)>=150 && Img(i,j)...


Similar Free PDFs