drawing clouds background* in matlab?

조회 수: 4 (최근 30일)
khurram
khurram 2012년 4월 9일
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

답변 (2개)

Jan
Jan 2012년 4월 10일
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
khurram
khurram 2012년 4월 10일
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 2012년 4월 10일
also the method u told for cropping was not working. i need that too.

댓글을 달려면 로그인하십시오.


Image Analyst
Image Analyst 2012년 4월 10일
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
khurram
khurram 2012년 4월 10일
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.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by