divide BMP to YUV channels

P

Pearce Pearce

Hey guys!
I have an univercity exersise:
I'm trying to get YUV channels from BMP picture, and output it like 3
grey images.
I know the proportion:
RGB to YUV
Y = (0.257 * R) + (0.504 * G) + (0.098 * B) + 16
V = (0.439 * R) - (0.368 * G) - (0.071 * B) + 128
U = -(0.148 * R) - (0.291 * G) + (0.439 * B) + 128

But don't know how to get it works with Ruby.

Thanks in advance!
 
M

Markus Schirp

Hello,

I dont think the ruby-ml, or the ruby-forums, are an exersise solving
machine...

But i can give you the following overall picture of your programm
(more pseudocode than ruby)

==== BEGIN

image = open_source_image

y_image = open_new_image
u_image = open_new_image
v_image = open_new_image

for pixel_in_image in image do
y,u,v = calculate_yuv_for_pixel(pixel)
write_to_image(y_image,y)
write_to_image(u_image,u)
write_to_image(v_image,v)
end

==== END

greetings,

Markus
 
M

Markus Schirp

Hola again,

Im reposting the pseudocode, since the first one leads to
uninitialized local variable 'pixel', renamed it to 'pixel_in_image'

image = open_source_image

y_image = open_new_image
u_image = open_new_image
v_image = open_new_image

for pixel_in_image in image do
y,u,v = calculate_yuv_for_pixel(pixel_in_image)
write_to_image(y_image,y)
write_to_image(u_image,u)
write_to_image(v_image,v)
end
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,085
Latest member
cryptooseoagencies

Latest Threads

Top