Matlab Assignment Essays Example
clc
clear;
%First Get "Canvas" Image.
im = imread('Mainpage.png');
imshow(im),title('Original Image')
subplot(2,2,1)
imshow(im);
b=imread('Fridgelist.png');
subplot(2,2,2)
imshow(b)
c=imread('FridgesFreezers.png');
subplot(2,2,3)
imshow(c)
I=imread('fluenciatable.jpg');
subplot(2,2,4)
imshow(I)
% display the image
mainCatalogImg = image(X);
% turn off the axis and markers
axis off
% scale the axis to the image size
axis image;
% the exit ICON upper left corner X and Y, as well as the button height and
% widths
exitIconX = 845;
exitIconY = 10;
exitIconWidth = 140;
exitIconHeight = 30;
% These values relate only to the icons use on the main catalog display,
% which was just loaded (ie MainPage.png)
iconWidth = 232;
iconHeight = 170;
% these points locate the upper left corner of each icon 1st position is
% X, and second position if Y
% X , Y
mainCatalogXYStarts = [ [22, 50];
[266, 50];
[510, 50];
[755, 50];
[22, 227];
[266, 227];
[510, 227];
[755, 227] ];
%while(1)
% ginput(1)
%end
% simple flag to control the main while loop
shopping = 1;
% simple flag to identify when an icon was actually clicked
iconClicked = 0;
% the MAIN loop
while( shopping )
% get a single mouse click from user
[xMouse,yMouse] = ginput(1);
% First check if exit button clicked
if( IsHit(xMouse, yMouse, exitIconX, exitIconY, exitIconWidth, exitIconHeight) )
shopping = 0;
close(mainWindow);
else
% Now we check which icon was actually hit, we do this by
% looping through each icon position and see if a hit was registered
% within the boundaries of the icon (remember we have the upper left
% corner X and Y corodinates as well as the height and width of the icons
for idx=1:length(mainCatalogXYStarts) % row centric icon counting
iconAnchorX = mainCatalogXYStarts(idx,1); % icon upper left corner X
iconAnchorY = mainCatalogXYStarts(idx,2); % icon upper left corner Y
iconClicked = IsHit(xMouse, yMouse, iconAnchorX, iconAnchorY, iconWidth, iconHeight);
% if we find the icon that was clicked then exit the FOR loop
% because we are done. The value of 'idx' continas the index of the
% icon that was clicked
if( iconClicked )
break;
end
end
end
% if an icons was clicked then do something interesting (well this code
% just opens the next catalog, passing the 'idx' value to indicate
% which catalog to display (if I had multiples)
if( iconClicked == 1)
disp(['Hit icon number ', num2str(idx)]);
iconClicked = 0; % reset it
ShowCatalog(idx);
end
end
- APA
- MLA
- Harvard
- Vancouver
- Chicago
- ASA
- IEEE
- AMA