convert a binary image to RGB color space

Hello, I have RGB image that I converted to binary to do some processing and I want to reconvert it back to its original color RGB, is it possible? I did some researchs on the internet but unfortunately I couldn't find a good answer. thank you in advance.

답변 (2개)

Walter Roberson
Walter Roberson 2015년 8월 24일

1 개 추천

No it is not possible. However, you can take
FilteredImage = repmat(YourBinaryImage, 1, 1, 3) .* YourColorImage;
if what you are doing is using YourBinaryImage to select which pixels should become black in your color image.
Image Analyst
Image Analyst 2015년 8월 24일

0 개 추천

You can't convert the binary image, but fortunately you should still have the original RGB image, don't you? If not, why not?

댓글 수: 5

Youssra
Youssra 2015년 8월 24일
편집: Youssra 2015년 8월 24일
hello, thank you all for your answer.
The main problem is that I'm working on color image watermarking, and basicaly I convert my watermak (logo) to a binary image then apply an embedding code, after that in extraction phase I got a binary extracted watermark that I need to convert to RGB to get it look like the original one. I'm working on blind watermarking wich means I can't use the original watermak for extraction
When you extract the bits, you get a vector of bit values, call it BitV.
ByteV = uint8( dec2bin(char(reshape(BitV, 8, []) .' + '0')) );
now that you have ByteV you can reshape() it into a 3D array of the appropriate size, which would be an image.
Youssra
Youssra 2015년 8월 24일
Thank you @Walter, I will try your answer and let you know ^^
Youssra
Youssra 2015년 8월 28일
Hello , I tried the answer that @ Walter gave me but I realised that the size of the result is completely different. for example I tried on 32*32 binary image (wich is RGB image originally) but at the end I got 1024*6 image and doesn't look like the original one :/
32 rows * 32 columns * 3 colors * 8 bits = 24576 bits embedded. Regroup the 8 bits and convert to bytes = 32 * 32 * 3 = 3072 bytes which happens to be 1024 * 3. I do not know where your factor of 2 came from: check to see how many bits your code embeds and how many bits it extracts. Once you get it down to 1024 * 3 then you rehape() that to 32 * 32 * 3.
1024 * 6 would make sense if your image is composed of uint16 instead of uint8, which is possible but not all that common.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Convert Image Type에 대해 자세히 알아보기

질문:

2015년 8월 24일

댓글:

2015년 8월 28일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by