Creating picture X*Y pixel by pixel

classic Classic list List threaded Threaded
3 messages Options
ZWD
Reply | Threaded
Open this post in threaded view
|

Creating picture X*Y pixel by pixel

ZWD
Hello,

I want to create a picture e.g. 640x480 and want to be able to change the color of each pixel.
So I want to create a picture pixel by pixel(and being able to say pixel on 235x198 has the color grey) and save it as a .jpg

Im a beginner in octave so any help would be great


Thanks
ZWD
Reply | Threaded
Open this post in threaded view
|

Re: Creating picture X*Y pixel by pixel

Massimiliano Minella
ZWD wrote
Hello,

I want to create a picture e.g. 640x480 and want to be able to change the color of each pixel.
So I want to create a picture pixel by pixel(and being able to say pixel on 235x198 has the color grey) and save it as a .jpg

Im a beginner in octave so any help would be great


Thanks
ZWD
You can create a .jpg picture with "imwrite"

> imwrite(A, "foo.jpg")

Create the image "foo.jpg" described by A, where A is a matrix m x n x 3 (in your case 640x480x3) and the third dimension represent the RGB color of your pixel.

HTH,
Max
Reply | Threaded
Open this post in threaded view
|

Re: Creating picture X*Y pixel by pixel

Martin Weiser-4
In reply to this post by ZWD
Cituji ZWD <[hidden email]>:

>
> Hello,
>
> I want to create a picture e.g. 640x480 and want to be able to change the
> color of each pixel.
> So I want to create a picture pixel by pixel(and being able to say pixel on
> 235x198 has the color grey) and save it as a .jpg
>
> Im a beginner in octave so any help would be great
>
>
> Thanks
> ZWD
> --
> View this message in context:  
> http://octave.1599824.n4.nabble.com/Creating-picture-X-Y-pixel-by-pixel-tp2318402p2318402.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> [hidden email]
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
>
>
Hello.
In octave, images are just matrices. Colour images are just 3 matrices  
(one for red, one for green, one for blue) bundled together  
(superimposed) into an 3D array.
So, create your matrices, eg. like this:
# prepare them
red=zeros(2,2)
green=zeros(2,2)
blue=zeros(2,2)

#"colour" pixels in them (0-255)

#red  matrix
red(1,1)=100

#green
green(1,2)=150

#blue one
blue(2,2)=200

# bundle them together
fig=cat(3,red,green,blue)

# if you want to see that figure
image(fig)

# if you want to save it as jpeg
imwrite(fig, "some_image_name.jpg")

Simple, is not it?
If you need just a monochromatic (eg. white-gray-black) figure, you  
need just a single matrix instead of 3D array.

So, I hope this helps.
Martin






_______________________________________________
Help-octave mailing list
[hidden email]
https://www-old.cae.wisc.edu/mailman/listinfo/help-octave