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('[Link]');
image(RGB)
imwrite(I,'[Link]','BitDepth',16);
CROPPING IMAGE
% Read RGB image from graphics file.
im = imread('[Link]');
% 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')