How to read any yuv image?
How can the dimensions of an YUV image be passed for reading to a buffer?
Usually, when people talk about YUV they talk about YUV 4:2:0. Your reference to any YUV image is misleading, because there are a number of different formats, and each is handled differently. For example, raw YUV 4:2:0 (by convention, files with an extension .yuv) doesn't contain any dimension data; whereas y4m files typically do. So you really need to know what sort of image you're dealing with before you start reading it. For YUV 4:2:0, you just open the file and read the luminance (Y') and chrominance (CbCr) components in that order, keeping in mind the chrominance components have been decimated (quarter size of the luminance components). After that you typically convert Y'CbCr to RGB so you can display the image.
From what I've mentioned above, you simply can't determine the dimensions of any YUV image. Often, the dimensions are simply not in the file. You have to know them up front -- this is why most sites listing YUV files for download also list their frame dimensions (and for video, the number of frames). Most YUV files are either CIF (352x288) or QCIF (176x144), although there are some files digitized from analog video that are in the slightly different SIF format. Read about the different formats here.
Related
Is it possible to trace back an image say a png image to a jpg? For example an image x.jpg that was converted to x.png. Is there a way of telling that x.png is essentially x.jpg, with the difference being formats?
If l convert img.jpg to img.png is it posssible for me to get back img.jpg?
I intend to check this in C.
As to your first question, the meta-information stored in PNG can tell what the original format or file was. But there is no requirement to store this meta-information in the file.
As to your second question: PNG is a lossless format. So if you decompress a Jpeg image into a bitmap and then encode that bitmap as PNG, you can at least get back from th PNG to the bitmap of the jpeg.
Getting back to the jpeg essentially means re-encoding (compressing) the bitmap, but to arrive at the bitwise identical Jpeg file means using the same compressor settings that were used to create the original Jpeg. As you probably don't know those settings (and it may depend on the compressor code too), I would say "No, you can't get back to the original Jpeg."
Where can I find YUV stereo test sequences? I have to use it for disparity compensation so I'll be needing the seprate left and right views. Thank you!
There are at least 2 digital libraries, which contain uncompressed stereo video in YUV 4:2:0 with separate-left-right-views format:
http://sp.cs.tut.fi/mobile3dtv/stereo-video/
FTP-download only, video resolution for YUVs is ~480x270. These sequences are not copyright-free, so contacting license file is useful.
http://nma.web.nitech.ac.jp/fukushima/multiview/multiview.html
Here you need 'Multiview sequence 1' and 'Multiview sequence 2'
HTTP-download possible. These sequences are actually multiview, it means they contain not only left and right views, but more of them. Any 2 views from there will be fine as stereo video.
RMIT3dv library may also be useful, but it contains uncompressed YUV 4:2:2 video in .MOV format, so you will need to perform some format conversion to get .yuv files. But video quality on this site is way better.
Link to this library will be the first answer to 'RMIT3dv' request to google.
I need to get the RGB value reading image. How can i do it in C?
The image format can be png,jpg,bmp or other usual format.
It has to be saved in a text file.
A very easy-to-use image library that can cover the reading and writing of all these formats would be FreeImage. It is primarily a C library, but there are also wrappers for C++, etc.
When you say "saved in a text file", that is pretty atypical for images due to the fact that binary formats are much more compact that storing raw string values for the pixel intensities. Additionally, many formats use compression, which would mean there isn't really a given "value" per-pixel ... instead the data must be decompressed before you can individually assign a value to every pixel. There are some image formats such as PPM that can be stored as ASCII data, but again, that's not necessarily the most efficient way to store a large image.
So for your workflow, you would use a library like FreeImage to read the values out of the image file, and then write back the uncompressed pixel values to a PPM file, or a custom-formatted text file.
I have some images (.bmp, .png, .jpg) in my directory. I want to convert this image to WORD array in order to display this image in LCD in 565 formats (16 bit pixel). How to convert an image to WORD array? Please help. Is is there any utility to just convert the image to binary? or Please provide some code in Windows C/CPP to convert it to binary?
This will depend a whole lot on the exact format of the input image.
Just converting "to words" isn't really expressing what you want to do, which is probably more like "convert bitmap images to an array of RGB565 pixels in row-major format".
You should look at image-processing libraries that allow you to load bitmap images, and read out the value of each pixel.
You can probably just convert directly to RGB565, shouldn't be too hard from any other bitmap format.
Note that there are both indexed and "true color" bitmap formats, and you sound like you need to handle both. If you'er lucky, the library for each format will abstract this away and have e.g. auint32 read_pixel_as_rgb888() function.
Also note that many bitmap image formats focus a lot on compression, which is why just reading in the bits of the file is not nearly enough, you need to de-compress the data according to the format. This is quite complex, which is why pre-written libraries are the only sane choice.
For PNG, look at libpng, for JPEG look for libjpeg. On second thought, these libraries might be a bit too low-level, and maybe you should look at something like SDL_Image instead.
You could try to use CImg to open image files - http://cimg.sourceforge.net/
I have a piece of source code that reads and writes images to PNG files. However, it only writes the images as grayscale, precisely just black and white.
Now, how do I modify it such that it would write to one of the channels in RGB (R or G or B is fine)?
Is there a short tutorial about that pixel manipulation with libpng?
It isn't small or nice written tutorial, but always something:
http://www.libpng.org/pub/png/libpng-1.2.5-manual.html