Jump to content

Talk:Color separation

From Rosetta Code

FreeBASIC solution seems to be wrong

For RGB and CMY programs, all the components have the same values, but the order changes. It means that if we mix all the produced images we would not get the original image, instead it would be a "grayscale" version of it.

For the CMYK model, if the program is a translation of Wren solution, it should produce the same result, providing they both use the same source image. Laurence (talk) 20:40, 30 July 2023 (UTC)

I just ran the RGB program and it is wrong. The problem lies with this section:
'' Create one pixel image for cada color.
Dim imgR As Any Ptr = Imagecreate(ancho, alto)
Dim imgG As Any Ptr = Imagecreate(ancho, alto)
Dim imgB As Any Ptr = Imagecreate(ancho, alto)
For y = 0 To alto-1
    For x = 0 To ancho-1
        col = Point(x,y)
        Pset imgR, (x, y), Rgb(col, 0, 0)
        Pset imgG, (x, y), Rgb(0, col, 0)
        Pset imgB, (x, y), Rgb(0, 0, col)
    Next x
Next y
where he's using the 24 bit color in the Pset commands rather than its red, green and blue components. To obtain the latter in a FB program, you typically define some macros to do the bit twiddling. This should fix it:
'' Create one pixel image for cada color.
#define RGBA_R(c) ( CULng(c) Shr 16 And 255 )
#define RGBA_G(c) ( CULng(c) Shr  8 And 255 )
#define RGBA_B(c) ( CULng(c)        And 255 )

Dim As UByte r, g, b

Dim imgR As Any Ptr = Imagecreate(ancho, alto)
Dim imgG As Any Ptr = Imagecreate(ancho, alto)
Dim imgB As Any Ptr = Imagecreate(ancho, alto)
For y = 0 To alto-1
    For x = 0 To ancho-1
        col = Point(x,y)
        r = RGBA_R(col)
        g = RGBA_G(col)
        b = RGBA_B(col)
        Pset imgR, (x, y), Rgb(r, 0, 0)
        Pset imgG, (x, y), Rgb(0, g, 0)
        Pset imgB, (x, y), Rgb(0, 0, b)
    Next x
Next y
I suspect what's happened here is that he's posted an earlier version of the code by mistake. It also looks like he may have pre-processed the images to get them into .bmp format and, in the case of the CMYK images, removed the text on the LHS in the process (I didn't bother doing this in my Wren solution). Incidentally, is the image used here AI generated as it seems too perfect to be real? --PureFox (talk) 08:38, 31 July 2023 (UTC)
Hi. I found the image in Pinterest. I actually was looking for a "realistic" image with many dark areas in order to show the savings of CMY inks due to an increment of black. Making a reverse search, I found that it was made by an artist: Eugene Borovik. He has made tons of images like that. Laurence (talk) 03:50, 1 August 2023 (UTC)
Wow, thanks. Whether he's using AI or not, it's quite a gallery of images! --PureFox (talk) 08:55, 1 August 2023 (UTC)
Cookies help us deliver our services. By using our services, you agree to our use of cookies.