Image Processing in MatLab

1 / 5

# Image Processing in MatLab - PowerPoint PPT Presentation

CS100: Into to Computer Science. Image Processing in MatLab. MatLab is a powerful tool to manipulate graphics and images. Prepared by Fred Annexstein University of Cincinnati Some Rights Reserved. WORKING WITH IMAGES in MatLab. Basic Image functions: Reading: img1=imread('image1.jpg');

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about 'Image Processing in MatLab' - kioko

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

CS100: Into to Computer Science

### Image Processing in MatLab

MatLab is a powerful tool to manipulate graphics and images

Prepared by Fred Annexstein

University of Cincinnati

Some Rights Reserved

WORKING WITH IMAGES in MatLab

Basic Image functions:

Writing:

imwrite(img1, 'image2.jpg');

Displaying:

imshow(img1);

Recall that Last time we did an Exercise: Find 2 images online and add them together.

You only needed to crop them to the same size.

WORKING WITH IMAGES in MatLab

RESIZING

>> [rows, cols, colors]= size(img)

% Increase the number of rows

>> stretchfactor = 1.5

>> rowVec= linspace(1,rows,stretchfactor*rows);

>> newrows=round(rowVec);

% Decrease number of columns

>> stretchfactor = 0.75;

>> colVec= linspace(1,cols,stretchfactor*cols);

>> newcols=round(colVec);

>> newimag=img(newrows,:,:)

>> imshow(newimg);

>> newimag=newimg(:,newcols,:)

>>imshow(newimg)

WORKING WITH IMAGES in MatLab

• Sometimes we want to replace pixels of an image of one or more colors with pixels from another image. It is useful to use a “blue screen” in some instances.
• Find an image with a big plot of one color. First we will replace that color. And then we will find another image for pixel replacement.
• Let us plot the color values of one chosen row…This will tell us the pixel values of the color we want to replace.
• image(v)
• row= input(‘which row?’);
• red = v(row,:,1);
• green = v(row,:,2);
• blue = v(row,:,3);
• plot(red,’r’);
• hold on
• plot(green,’g’);
• plot(blue,’b’);

WORKING WITH IMAGES in MatLab

• Suppose we want to replace those values whose intensities exceed a threshold value of 160 in each color.