Hi, I am trying to quantify the symmetry of logo images. So far, I have used the "immse" (mean square error) function and the "fliplr" in MatLab to compare the differences in mean square error (MSE) between the originial logo and the flipped version of the logo to quantify the symmetry. I am experiencing one issue atm with this approach and I need your help... When analysing logos that are 100% symmetric, the MSE can sometimes be super high when it should be extremely close to zero, since theres no differences between the original and flipped version. What may the issue be here? and any ideas on how to solve it?

댓글 수: 4

Geoff Hayes
Geoff Hayes 2020년 5월 19일
Sebano - would using fliplr and expecting a very small MSE be true only if the logo is in the exact centre of the image? What happens if you compare the original and the flipped image (side-by-side, one over top of the other, etc.)?
Walter Roberson
Walter Roberson 2020년 5월 19일
For example, imsubtract()
It would help for you to upload an image you are having trouble with.
Note that if you are using .jpg for this work, that .jpg blurs edges, and does so in a way that is not symmetric.
Sebano
Sebano 2020년 5월 23일
How can I make sure that its divided in the exact middle? What is the code to do this? Thanks.
Sebano
Sebano 2020년 5월 23일
E.g. What I use the following codes to analyze the symmetry of Starbucks logo:
>> Starbucks = imread('132. Starbucks logo.png');
>> imshow(Starbucks);
>> [rows, columns, numberOfColorBrands] = size(Starbucks);
>> if numberOfColorBrands > 1
grayImage = rgb2gray(Starbucks);
else
grayImage = Starbucks;
end
>> imshow(grayImage);
>> immse(grayImage, fliplr(grayImage));
>> imshow(grayImage);
>> imshow(grayImage, fliplr);
The MSR is results in 298... Even when the logo is very symmetric logo! The MSR should be very close to zero... Any recommendations for how to make sure this is done correctly? I have attached the logo file above.

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

 채택된 답변

Walter Roberson
Walter Roberson 2020년 5월 23일

0 개 추천

regionprops(double(grayimage>0), 'centroid')
and observe that the centroid is 1 pixel to the right of where you would expect.
So construct a new image that is padded on the right with one column of 0. Run the immse and you will see a lower value.
I recommend that you imshow(imsubtract()) the two images to see visually how they are not quite symmetric. As I discussed earlier some of the problem is jpg blurring of edges.

추가 답변 (1개)

Image Analyst
Image Analyst 2020년 5월 23일
편집: Image Analyst 2020년 5월 23일

1 개 추천

You have to make sure you're truly flipping about the true vertical axis, which I suspect you're not. You'd have to get rid of the TM in the Starbucks logo that is making the whole logo not symmetric.
Usually symmetry is computed using a symmetry metric like the Sørensen–Dice coefficient.
See attached demo.

댓글 수: 11

Tengbo Zhuang
Tengbo Zhuang 2020년 7월 1일
Hi! Thanks for the code. This actually works! But I am just wondering somehow, I was testing some logos, it shows that the number is actually above 1. Cause I thought the value shall between 0-1 instead. If it shows higher than1, what does that mean? Thanks!
Image Analyst
Image Analyst 2020년 7월 1일
Could be due to digitization error. Did you look at the pixels that it said were not in both views?
Tengbo Zhuang
Tengbo Zhuang 2020년 7월 2일
So it might be the problem of the image itself? I haven't checked the pixels tho but I can try to use different images instead.
Have another question actually, cause when I tested Microsoft, it shows the coefficient is 1, which makes sense. However, when I tested amazon logo, it also shows 1, same as Apple. I am wondering does it make sense to the amazon logo & apple logo instead? Thanks!
Image Analyst
Image Analyst 2020년 7월 2일
Yes, there could be a fews pixels that are different on the right and left side. By the way, neither the Microsoft logo, Amazon logo, or Apple logo are very symmetric. The Microsoft logo would only be symmetric if you discarded the letters "Microsoft" and converted the squares to binary (ignoring the colors), but then that's not the Microsoft logo anymore.
Tengbo Zhuang
Tengbo Zhuang 2020년 7월 2일
Yes! I actually tested the Microsoft logo without the "Microsoft letter". It just really werid that I use Amazon logo & apple logo, they all present coeffient as 1, which is actually impossible. So I wonder maybe its because the image file? Cause all the file type I used is png instead.
Image Analyst
Image Analyst 2020년 7월 2일
Attach the logo files you're using if you need more help.
Tengbo Zhuang
Tengbo Zhuang 2020년 7월 2일
Like these two logos, which shall be completely opposite from being symmetric. But the result shows 1 instead.
That demo gets the two images by thresholding at two different gray levels. You don't want to do that. You'd want to get the second image by using fliplr() instead of thresholding at a different level. Perhaps I should add that option to the demo, but as of now, it's not like that, so you need to get image2 from image1 like this on line 58:
% Create the binary images.
binaryImage1 = grayImage > lowThreshold;
binaryImage2 = fliplr(binaryImage1);
Tengbo Zhuang
Tengbo Zhuang 2020년 7월 2일
Ah I see! No wonder. So after I code binaryImage2 = fliplr(binaryImage1);
I can do andImage = binaryImage1 & binaryImage2. Then I shall be also to the correct coefficient. (?)
Also one more question, is that there one code:
[lowThreshold, highThreshold] = GetThersholds(pixelCount, grayLevels);
It shows that the GetThersholds is an invaild code. Does that happen to you as well?
Thanks a lot for the help!
It was in the file:
%===============================================================================
% Get the thresholds from which we'll use to create two binary images:
function [lowThreshold, highThreshold] = GetThresholds(pixelCount, grayLevels)
cdf = cumsum(pixelCount);
cdf = cdf / cdf(end);
lowPercentage = 20;
lowThresholdIndex = find(cdf > lowPercentage / 100, 1, 'first');
lowThreshold = grayLevels(lowThresholdIndex);
highPercentage = 40;
highThresholdIndex = find(cdf > highPercentage / 100, 1, 'first');
highThreshold = grayLevels(highThresholdIndex);
Looks like you changed the name when you called it from GetThresholds to GetThersholds.
Tengbo Zhuang
Tengbo Zhuang 2020년 7월 2일
Right! Didn't notice that
I just tested Apple, I think it works now! (0.85) Thanks a lot!

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

카테고리

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

질문:

2020년 5월 19일

댓글:

2020년 7월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by