GNU Octave/Tworzenie rysunków: Różnice pomiędzy wersjami

Usunięta treść Dodana treść
m →‎Przetwarzanie obrazów: kolejność arg
Linia 122:
for ix= 1:nx
# tu możemy zmieniać kolor poszczególnych pikseli
end # for ix
waitbar(iy/ny);
end # for iy
image(MyImage); # wyświetla obraz
imwrite(MyImage,'s.jpgpng' ); # zapisuje obraz do pliku s.jpgpng ; wymaga ImageMagic
 
 
Bardziej zaawansowany przykład :
 
<source lang="matlab">
# octave m-file based on the m-file by Chris King
# http://www.dhushara.com/DarkHeart/Viewers/source/siegel.m
# an MyImage here is a matrix for 24 bit (3 byte) colors
 
# load packages
pkg load image; # imwrite
pkg load miscellaneous; # waitbar
 
# constan values
nx = 480;
ny = 480;
MyImage = zeros(ny,nx,3); # 2D matrix filled with zeros
magc=0.65;
dSide=1/magc;
Zxmin = -dSide;
Zxmax = dSide;
Zymin = -dSide;
Zymax = dSide;
 
stepy = (Zymax - Zymin)/(ny - 1);
stepx = (Zxmax - Zxmin)/(nx - 1);
 
# computations
waitbar(0,'Please wait...'); # info
for iy = 1:ny
Zy = Zymax - iy*stepy; # invert y axis
for ix= 1:nx
Zx = Zxmin + ix*stepx;
if(Zy>0 && Zx>0) # first quadrant should be in upper right position
MyImage(iy,ix,2)=255-MyImage(iy,ix,2);
endif;
end # for ix
waitbar(iy/ny);
end # for iy
#
image(MyImage); # display image
imwrite(MyImage,'s.png' ); # save image to the file
</source>
 
Ogólny schemat przetwarzania obrazów :<ref>[http://www.gnu.org/software/octave/doc/interpreter/Image-Processing.html octave doc : Image Processing]</ref>