0% found this document useful (0 votes)
44 views

STR Input (Prompt,'s') Enter The Value 5: Input and Output Interpretation

This document discusses different ways of getting input from and providing output to users in MATLAB. It demonstrates how to get string and graphical input, store values based on conditions, and read, write, display and manipulate image files. Key functions and operations include input, ginput, imread, imwrite, image, cropping images by indexing into pixel coordinates, and displaying output.

Uploaded by

Anirudhh Ravi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

STR Input (Prompt,'s') Enter The Value 5: Input and Output Interpretation

This document discusses different ways of getting input from and providing output to users in MATLAB. It demonstrates how to get string and graphical input, store values based on conditions, and read, write, display and manipulate image files. Key functions and operations include input, ginput, imread, imwrite, image, cropping images by indexing into pixel coordinates, and displaying output.

Uploaded by

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

INPUT AND OUTPUT INTERPRETATION

GETTING VALUE FROM USER


str=input(prompt,'s')
Enter the Value 5

str =

' 5'
STORING A STRING VALUE FROM A CONDITION USING IF
prompt = 'Do you want more? Y/N [Y]: ';
str = input(prompt,'s');
if isempty(str)
str = 'Y';
end
GRAPHICAL INPUT FROM USER
[x,y] = ginput(4)

x =

0.3295
0.3971
0.6352
0.4693

y =

0.8395
0.7014
0.5321
0.3006

>> plot(x,y)

IMAGE PROCESSING

READ, WRITE AND QUERY IMAGES


RGB = imread('ngc6543a.jpg');
image(RGB)
imwrite(I,'clown.png','BitDepth',16);

CROPPING IMAGE
% Read RGB image from graphics file.
im = imread('street2.jpg');

% Display image with true aspect ratio


image(im); axis image

% Use ginput to select corner points of a rectangular


% region by pointing and clicking the mouse twice
p = ginput(2);

% Get the x and y corner coordinates as integers


sp(1) = min(floor(p(1)), floor(p(2))); %xmin
sp(2) = min(floor(p(3)), floor(p(4))); %ymin
sp(3) = max(ceil(p(1)), ceil(p(2))); %xmax
sp(4) = max(ceil(p(3)), ceil(p(4))); %ymax

% Index into the original image to create the new image


MM = im(sp(2):sp(4), sp(1): sp(3),:);
% Display the subsetted image with appropriate axis ratio
figure; image(MM); axis image

% Write image to graphics file.


imwrite(MM,'street2_cropped.tif')

You might also like