drawing clouds background* in matlab?
Mostra commenti meno recenti
hi everyone, i started using matlab about 3 months ago and am just aware of the basic computing i.e. for loops , while loops, if conditions. i have been given a game as a project. i was thinking of drawing its graphics first. i wanted to draw moving clouds in the background. i do not know any function to draw this nor could i think of any way to somehow create my own function. kindly help me in doing that. regards, khurram
Risposte (2)
Jan
il 10 Apr 2012
You can draw an image in an axes object:
AxesH = axes('Units', 'normalized', 'Position', [0, 0, 1, 1]);
img = imread('clouds.jpg'); % <- your file name here
image(img, 'Parent', AxesH);
Now you can crop the wanted rectangle from the loaded image, e.g. by:
moved = img(1:200, 1:300)
Image Analyst
il 10 Apr 2012
Try this demo. I wrote it using Peter Kovesi's program. Be sure to download his m-file like my instructions say to. This program will generate cloud images one at a time until you say quit.
% Demo to make cloud-like images.
% Uses the noiseonf routine of Peter Kovesi:
% Copyright (c) 1996-2005 Peter Kovesi
% School of Computer Science & Software Engineering
% The University of Western Australia
% http://www.csse.uwa.edu.au/
% You can download noiseonf.m here:
% http://www.csse.uwa.edu.au/~pk/Research/MatlabFns/Misc/noiseonf.m
clc;
close all;
workspace;
clear;
fontSize = 16;
index = 1;
for h = 0.5:.1:3
%===============================================
% Create the image.
% THIS IS THE KEY PART!
grayImage = noiseonf(800, 1.7);
%===============================================
% Display it
imshow(grayImage, []);
% Enlarge figure to full screen.
% Need to re-enlarge it every single time for some reason.
set(gcf, 'Position', get(0,'Screensize'));
set(gcf,'name','Clouds Demo','numbertitle','off')
if index == 1
promptMessage = sprintf('I will show you images like this one.\nClick Accept when you see an image you like.');
button = questdlg(promptMessage, 'Instructions', 'Continue. Try Another', 'Accept this one', 'Quit Program', 'Continue. Try Another');
if strcmpi(button, 'Accept this one') > 0
break;
elseif strcmpi(button, 'Quit Program') > 0
close all;
return;
end
index = index + 1;
else
promptMessage = sprintf('This is h = %.1f', h);
title(promptMessage, 'FontSize', fontSize);
button = questdlg(promptMessage, 'Instructions', 'Continue. Try Another', 'Accept', 'Quit Program', 'Continue. Try Another');
if strcmpi(button, 'Accept') > 0
break;
elseif strcmpi(button, 'Quit Program') > 0
return;
end
end
end
% Convert to a uint8 (8 bit gray scale) image.
% grayImage = uint8(255 * mat2gray(grayImage));
uiwait(msgbox('Done with demo!'));
1 Commento
khurram
il 10 Apr 2012
Categorie
Scopri di più su Images in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!