drawing clouds background* in matlab?

7 visualizaciones (últimos 30 días)
khurram
khurram el 9 de Abr. de 2012
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

Respuestas (2)

Jan
Jan el 10 de Abr. de 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)
  2 comentarios
khurram
khurram el 10 de Abr. de 2012
exactly....i wanted something like this.
i copied this code into matlab and it worked fine but i cant seem to understand it. i wrote help units,normalized into the command window but could not figure out anything.kindly help me understand the function. i mean tell me a bit what "units" 'normalized' 'position' and 'parent' do in this case.thanks.
khurram
khurram el 10 de Abr. de 2012
also the method u told for cropping was not working. i need that too.

Iniciar sesión para comentar.


Image Analyst
Image Analyst el 10 de Abr. de 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 comentario
khurram
khurram el 10 de Abr. de 2012
the code works fine but i wanted something that i could understand. this is too difficult. also i wanted a bit animated picture. thanks anyway. i got another way.

Iniciar sesión para comentar.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by