Gimp switch color channels - framebuffer

I'm capturing a raw framebuffer on an embedded device. The framebuffer is 32bit BGRA color mode
cp /dev/fb0 framebuffer.data
I can transfer the raw dump to my PC and import it into GIMP, but GIMP only allows me to read the raw data as if it were ARGB, which results in incorrect colors. Is there a way to just switch the red and blue channels in GIMP?

What you could try in GIMP is to use the channel mixer - it allows to mix new RGB components out of the image's original RGB components.
In the screenshot, I've taken a simple image with a red, green and a blue column, and told the channel mixer to turn red into green, green into blue and blue into red. Original colors are shown in the lower half, transformed ones in the upper half of the image.

I found a way around this by using gstreamer to convert the color and do the screencap...
#!/bin/bash
cp /dev/fb0 /home/root/framebuffer.data
gst-launch-1.0 filesrc location="/home/root/framebuffer.data" ! rawvideoparse use-sink-caps=false width=800 height=1280 format=bgra ! imxvideoconvert_ipu ! videoconvert ! pngenc snapshot=false compression-level=1 ! filesink location=/home/root/screencap.png
rm /home/root/framebuffer.data

Related

Can a PNG image that is entirely opaque contain an alpha channel?

Is it possible to construct a png image, that is entirely opaque (that means every pixel in the image is opaque) but the image data itself has an alpha channel ?
Why is it that some PNG images don't have an alpha channel ?
Yes. Just like an RGB image may contain only data in the Red channel and not in Green and Blue; "unused" channels are not a problem. Alpha is a separate channel of its own, and in particular, its values should be independent of the associated pixel colors: "PNG does not use premultiplied alpha" (6.2 Alpha representation).
Also see 12.4 Alpha channel creation in the official specifications for some additional details:
The alpha channel can be regarded either as a mask that temporarily hides transparent parts of the image, or as a means for constructing a non-rectangular image. In the first case, the colour values of fully transparent pixels should be preserved for future use. In the second case, the transparent pixels carry no useful data and are simply there to fill out the rectangular image area required by PNG. In this case, fully transparent pixels should all be assigned the same colour value for best compression.
Because they don't need to, per that same specification:
... PNG provides a patent-free replacement for GIF and can also replace many common uses of TIFF. Indexed-color, grayscale, and truecolor images are supported, plus an optional alpha channel. (my emphasis)

To substitute lsb value of rgb image with character

I want to substitute LSB of rgb image with character. I have done it for gray sacle image using bitset and bitget. Can I use same logic for rgb image?
Here is part of code which I have used:
stego=zeros(size(img))
stego=bitset(stego,1,lsp)
Where img is cover image and lsp is binary message. I have then merge bitplanes by:
stego=bitset(stego,2,bitget(img,2))
Up to 8th plane to get the strgo image.
How can I build the same logic for RGB image? Please guide me.

Image Magick: convert and composite in one command

I am currently working on a automation script to convert imgaes for use on websites. Every image gets a white and black border and is combined with a prepared alpha channel image. The black border (outer border) combined with the alpha channel will look like a shadow when everything is done.
I've got the following files:
test.jpg (the test image)
test.tga (the alpha channel)
And I convert the input image in 2 steps:
convert test.jpg -bordercolor #FFFFFF -border 15 -bordercolor #000000 -border 30 test.png
(adds the white and black border to the image and saves as 'test.png')
composite -compose CopyOpacity test.tga test.png test2.png
(joins image file with alpha channel from test.tga and saves as test2.png)
So now my question is: Is there any way to invoke both steps as one command? I know that convert also supports the -compose options, if I got that right from the manual, but I could not get it working. It would be best, if I could edit and join the image with the alpha channel with one command. (Command will be executed from my Application and I don't want to execute many sub-processes)
Maybe someone knows a solution for this.
Thanks in advance!

How to convert a black and white photo that was originally colored, back to its original color?

I've converted a colored photo to black and white, and bolded the edges. Now i need to convert it back to its original color with the bolded edges. Is there any function in matlab which allows me to do so?
Once you remove the colour from an image, there is no possible way to automatically put it back. You're basically reducing a set of 16,777,216 colours to a set of 256 - on average each shade of grey has 65,536 equivalent colours, and without the original image there's no way to guess which it could be.
Now, if you were to take the bolded lines from your black-and-white image and paint them on top of the original coloured image, that might end up producing what you're looking for.
If what you are trying to do is to use some filter over the B/W image and then use that with the original color. I suggest you convert your image to a color space with Lightness channel that suits your needs (for example L*a*b* if you need the ligtness to be uniformly distributed regarding human recognition of differences) and apply your filter only over the Lightness channel.

How to change background color of an eps file while converting it to jpeg or png

I am converting eps (Encapsulated PostScript) files to jpeg files with ghostscript. A sample command I use is:
gswin32.exe -sDEVICE=jpeg -dJPEGQ=100 -dNOPAUSE -dBATCH -dSAFER -r600x600 -dGraphicsAlphaBits=4 -dUseCIEColor -dEPSCrop -sOutputFile=”a.jpeg” b.eps
The input eps files come with white backgrounds (I only have their clipping path). What I need to do is change this white background to another color in the output images, or it would be even better if I could make them transparent (output file format would be png). How can I do this?
never tried it myself but you should be able to convert your eps file into png by setting:
-sDEVICE=pngalpha
also the pngalpha device has a -dBackgroundColor option:
-dBackgroundColor=16#RRGGBB (RGB color, default white = 16#ffffff) For
the pngalpha device only, set the
suggested background color in the PNG
bKGD chunk. When a program reading a
PNG file does not support alpha
transparency, the PNG library converts
the image using either a background
color if supplied by the program or
the bKGD chunk. One common web browser
has this problem, so when using on a web page you
would need to use
-dBackgroundColor=16#CCCC00 when creating alpha transparent PNG images
for use on the page.
more details here: Details of Ghostscript output devices see section 3.1. PNG file format
After you've obtained your (white background) images from Ghostscript, you could use ImageMagick's convert or GraphicMagick's gm convert commands to change the white to transparent background:
convert -background transparent my.png my_transp.png