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!
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
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