How we can maximize PSNR between RGB image and binary(0,1) image?
Afficher commentaires plus anciens
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
Réponse acceptée
Plus de réponses (3)
yanqi liu
le 18 Nov 2021
1 vote
sir,may be use
if ndims(im) == 3
im = rgb2gray(im);
end
im = double(im2uint8(mat2gray(im)));
to get the same data type
3 commentaires
mohammad nemat
le 18 Nov 2021
yanqi liu
le 19 Nov 2021
sir,may be use direct threshol,such as
img=imread('./test.png');
im2=img(:,:,1)>50;
b = PSNR(img,im2);
mohammad nemat
le 19 Nov 2021
Yusuf Suer Erdem
le 20 Nov 2021
0 votes
I was not able to implement your codes into that probably psnr funtion only allows limited data types.
1 commentaire
mohammad nemat
le 20 Nov 2021
Image Analyst
le 20 Nov 2021
0 votes
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 commentaires
mohammad nemat
le 20 Nov 2021
Image Analyst
le 21 Nov 2021
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.
Catégories
En savoir plus sur Signal Attributes and Indexing dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!







