- “fprintf" documentation: Display value of variable - MATLAB disp
- “flip” image in MATLAB: Flip order of elements - MATLAB flip
- “imabsdiff” to calculate the difference of two images: Absolute difference of two images - MATLAB imabsdiff
Is there a way to quantify symmetry in a Image or a CAD file
2 次查看(过去 30 天)
显示 更早的评论
I have a image or a CAD file such as below where I want to quantify assymetry. In the image shown as can be seen visually the blue line in the right is assymetric in relation to the other blue line versus the orange line. Is there a assymetricty metric which one can think about ? Any inputs here will be valuable.
0 个评论
回答(1 个)
Suvansh Arora
2022-11-4
One of the possible ways to quantify the symmetry of an image is to calculate the “Manhattan Norm”.
Please look at the helper function below to calculate the “Manhattan Norm”:
%% Manhattan Norm: To check the Symmetry of Image
%
% man_norm = Img - Img_Flipped;
%
% man_norm_per_img = (Img - Img_flipped)/size(Img);
function [man_norm, man_norm_per_img] = imageSymmetry(Img)
% Horizontal Flipping the Image
Img_Flipped = flip(Img, 2);
% Calculate size of image
[height, width, dim] = size(Img);
% Manhattan Norm calculation
man_norm = sum(imabsdiff(Img, Img_Flipped), 'all');
% Manhattan Norm per pixel calculation
man_norm_per_img = man_norm / (height * width * dim);
end
In order to view the symmetry of an image, call the above helper function:
Img = imread('me.jpg');
help imageSymmetry
[man_norm, man_norm_per_img] = imageSymmetry(Img);
fprintf('Manhattan norm: %d / per pixel: %d\n', man_norm, man_norm_per_img);
In order to know more about the functions used, please follow the documentation below:
I hope the above information helps you.
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!