How we can maximize PSNR between RGB image and binary(0,1) image?
2 次查看(过去 30 天)
显示 更早的评论
Hi, I have one RGB image and i want to create binary image from that with maximum PSNR. How i can do that?
In another word, The goal we are pursuing here is to make the output black and white image look like
Most images are the original color image from a PSNR perspective
0 个评论
采纳的回答
Yusuf Suer Erdem
2021-11-15
Converting segmented RGB images into GRAYSCALE form is really good idea to process them.
14 个评论
DGM
2021-11-21
You can certainly get a number, but again, what is the meaning of the comparison between these two images? The images are not remotely similar.
A = imread('peppers.png');
im2=imbinarize(A);
im2=uint8(im2);
b = psnr(A,im2) % it's a number
imshow(A); % the original RGB image
figure;
imshow(im2); % it's an approximately black RGB binary image
You mention trying to replicate imbinarize, but imbinarize doesn't do what you're describing. The closest might be the 'adaptive' method. If that's what you're after, just open up imbinarize() and read it. The private functions it calls should be in the toolbox directory.
更多回答(3 个)
Yusuf Suer Erdem
2021-11-20
I was not able to implement your codes into that probably psnr funtion only allows limited data types.
Image Analyst
2021-11-20
I agree with what Yusuf and DGM said, especially DGM who came up with a clever solution. He should post it as his own answer so we can vote for it and award him reputation points. They asked why you think you need it and that it may be irrelevant. Even when DGM specifically asked you why you need it you didn't really answer and just said basically "I need it because I need it" which is a non-answer. PSNR is usually used in comparing compression techniques, not comparing a 24 bit image to a 1-bit image. So what will you do with the thresholds DGM came up with?
2 个评论
Image Analyst
2021-11-21
OK, I'll try to explain what I was thining about. When DGM and I asked you why you need a threshold to "maximize PSNR between RGB image and binary(0,1) image", your answer was that the reason why was in the title which is that you need to "maximize PSNR between RGB image and binary(0,1) image". So that's why I said you basically said "I need it because I need it."
Let's look at it a different way. Let's assume I asked you "I need a doohickey. Can you make me a doohickey?" And you replied "Why do you need a doohickey?" And I just replied "I already told you why -- I need a doohickey!"
Alright here is a common scenario.
- Person Q says "I need X".
- So person A makes X for Q and turns it over to Q.
- Then person Q says "That's no good - it doesn't work."
- A says why not?
- Q says "because it doesn't get me Y."
- A says "Well you didn't ask for Y initially. You only asked for X. But now since you tell me you want Y, I can tell you that getting X will not get you Y and is, in fact, the wrong approach that you asked for. If you really want Y, you need to do Z"
- A does Z and hands it over to Q, who is now happy with the solution.
That happens all too often and is why we need the full context of what you're trying to do.
In your situation you're asking how to do something that three people are telling you doesn't make sense and in meaningless and useless. You never said why so now I'm assuming it may be one of those quirky homework problems that essentially has no real world use. Often times, and I'm not saying that it applies to you, but people ask questions to try to get people to do their homework problems for them but they don't want to admit it because people will then just give them hints instead of full solutions. This is because some professors use plagiarism detectors to see if the student just copied code from an online forum, and we don't want them to get into trouble. That's why we often see code posted as an image instead of text - so the plagiarism detectors won't find it. Again, not saying that's you. Despite asking for the need, you have not said it's your homework so we'll assume it's not, but we just don't know why someone would ask for such a weird thing. Nevertheless, DGM tried to give you something you mght be happy with. We want to give you Y so you can get Z but you keep saying you need X.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Denoising and Compression 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!