Deference of YCrCb and YUV - yuv

I was working on a image format converter, and I was trying to convert YcbCr to RGB. For the testing purpouse I was Looking for YcbCr formated image. Googling it always gives result of YUV, rather yCrCb.
Are those formats same?
is there any way to download (or convert) YCbCr Image ?

Related

YCbCr to RGB conversion MATLAB using ycbr2rgb results in pink picture

I'm trying to convert an YCbCr image to RGB ysing MATLAB's function ycbcr2rgb. My resulting picture ends up being pink, and converting back again afterwards (should give me the original picture?) creates yet another image mostly grey.
For reference I tried to convert each channel individually by formula and it ends up the same.
I'm using a bigtiff format because of large filesize and if any help the imfinfo shows compression using JPEG.
Here is my code:
x=imread('picture.tiff','Index',9); %(9 subresolutions)
rgb=ycbcr2rgb(x);
imshow(rgb);
Can it be because of MATLABs function using the originial definition of YCbCr using ranges from 16-235 while my image is ranging from 0-255? If so is there any means of correcting this using the inbuild function?
I have added the pictures here, first image is showing imshow(rgb), while the second image is the original ycbcr. What I noticed is that in the Windows image viewer it actually shows it correct, it's just MATLAB's imshow that displays it pink after conversion.
Is there any chance you could point me in the right direction?
Thanks
Sonny
Apparently imread reads YCbCr images as RGB when loading it, which is why the problem occured.
Thanks for the help to all of you.
imread documentation
This link gives all the conversion formulae:
http://www.easyrgb.com/index.php?X=MATH&H=11
The below code converts image from RGB space to YCbCr space and back.
rgb = imread('board.tif');
imshow(rgb);
figure;
ycbcr = rgb2ycbcr(rgb);
imshow(ycbcr);
figure;
rgb2 = ycbcr2rgb(ycbcr);
imshow(rgb2);
Use MATLABs built in functions only. Also, if you're facing issues while converting from ycbcr to rgb you should probably try to convert the image to other form and then convert that form to RGB. (a dirty hack)
Just divide the image by 256 before converting it back to RGB.
y = ycbcr2rgb(z/256); % z holds the YCbCr image.
Worked for me.
Hope that helps :)

Why do YCbCr channels saved as jpeg images,the pixels' values change?

I used the function rgb2ycbcr in matlab R2013a to change RGB to YCBCR color space. And I saved each channel of YCBCR as a jpeg image.Then I read the jpeg image,for example CB channel,but I found the pixel value is different in the jpeg image with the channel CB before saved. Why does this happen? Here is my code:
I = imread('pic.jpg'); % // 'pic.jpg' is an unin8 rgb image
YCBCR = rgb2ycbcr(I);
Y = YCBCR(:,:,1);
CB = YCBCR(:,:,2);
CR = YCBCR(:,:,3);
imwrite(Y,'F:\CASIA V1.0\Y.jpg','jpg');
imwrite(CB,'F:\CASIA V1.0\CB.jpg','jpg');
imwrite(CR,'F:\CASIA V1.0\CR.jpg','jpg');
Then I read the CB.jpg, I found the pixel value is different with those in YCBCR(:,:,2). Is anything wrong with my code? I will be very grateful if anybody can answer my question.
When you use imwrite to store an image as a jpg, it runs jpeg compression on the image before saving it to file. By default, the compression quality is set to 75% of the original. I'm guessing this is the reason behind some pixel values changing from the uncompressed images to the compressed ones.

Why dicom image displayed are inverse colour and lossy for output. (Matlab)

Why are the colours inversed when I read a DICOM file? Also, when I am try to stretch and adjust the image output the export files are lossy (TIFF):
origImg = dicomread(uigetfile('~/matlab/*.*', 'Select Dicom File'));
J=imadjust(origImg,stretchlim(origImg),[0 1]);
CExpo = adapthisteq(J,'Distribution','exponential','Alpha',3);
imwrite(CExpo,'finish.tif','Resolution',100);
Resource and compare file: https://www.mediafire.com/?2xcwpt4khw3qh06
Matlab's Tiff class inverts uint8 image values when PhotometricInterpretation is 'Separated'. The Tiff specification specifically forbids this, but Matlab does it anyway for reasons unknown to me. That probably answers why your images are inverted. Generally speaking, Tiff images are not a lossy format, so if you believe there is a loss of fidelity, I do not understand how that is happening. (Nor do I know what a dicom image is).

Matlab Convertion of HSV type in Matlab

I'm looking for making image corrections in a movie using matlab.
I've googling for examples to splitting the movie into images, and then another example to improve image's quality.
As I'm using several examples, I got into a issue and I was wondering if it is possible to convert an HSV image into a uint8 type?
If your HSV image is of type double and the range lies between 0 and 1 then you might have luck by multiplying it by 256 and casting to uint8:
HSVuint8 = uint8(HSV.*256);
You can convert any HSV image into RGB using hsv2rgb
Once converted you

Image Conversions in Matlab

I converted an RGB image (which is in double format) to a gray scale image of the same format using rgb2gray in Matlab. Now I want to convert the same image from gray to RGB. I used gray2rgb in Matlab but it's giving an error. So how can we convert a grayscale image to an RGB image using Matlab?
Short answer: you can't. Not perfectly at least.
As Sean says, this is because you have dropped some information when converting to grayscale. In other words, converting back from grayscale to RGB is an under-determined inverse problem, so there is no easy solution.
Now this doesn't mean you can't try. If you have some prior on the image, you can use it in addition to the information you have left to compute an estimate of the original RGB image.
For example if you know (or suppose) that the original image was already grayscale (in an RGB container) then you can reverse the process exactly. This is what the gray2rgb function Sean mentions is doing.
Most of these are open problems, so it's probably beyond what you want.
I'm sorry to say it's not possible.
By converting the image to grayscale you've reduced the amount of information (3 dimensions at each pixel down to 1) and this can't be recovered.
The rgb2gray function is one included in Matlab and works fine.
The gray2rgb function is not a standard Matlab function. If you are referring to this function on Matlab central, it's documentation states it doesn't do anything useful but just creates a 3d matrix from the 1d matrix; the image will still be grayscale.