To find aspect ratio of an image using matlab

I have done code to find aspect ration of an image, but i didn't get the actual value some time.Is the code correct to find aspect ratio,If not please tell me the alternate way to solve the problem. Thank you.
srcFiles = dir('C:\Users\meghnad\Desktop\New folder\*.jpg');
for i = 1 : length(srcFiles)
filename = strcat('C:\Users\meghnad\Desktop\New folder\',srcFiles(i).name);
E = imread(filename);
level = graythresh(E);
BW = im2bw(E,level);
[m,n]=size(BW);
AR=m/n
end

답변 (1개)

Iman Ansari
Iman Ansari 2013년 4월 16일

0 개 추천

Hi. I think n/m:
E = imread('peppers.png');
m=size(E,1);
n=size(E,2);
AR=n/m

댓글 수: 2

Jagdeep
Jagdeep 2014년 9월 13일
hi i am new to matlab. Can you please tell how your above statements work particularly from 2 to 4.
It gives you the size of the dimensions, with dimension 1 being rows, dimension 2 being columns. AR is the ratio of the number of columns to the number of rows, which is the aspect ratio.

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

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

질문:

2013년 4월 16일

댓글:

2014년 9월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by