code for gender classification using mallab:ERROR
1 次查看(过去 30 天)
显示 更早的评论
hi!
im new, and a complete newbie in the realm of DIP, recently received a project from my supervisor ; gender classification through matlab!
so its quite simple just checks if the guy has a beard then output man and if not then output women(very simple because its a small project and we have zero background in DIP)
here is the code:
image=imread('C:\Users\mustafa\Downloads\scarlett_johansson-2.jpg');
R = image(:,:,1);
G = image(:,:,2);
B = image(:,:,3);
z=imshow(image);
resizeImage = imresize(image,[120 160]);
R = resizeImage(:,:,1);
G = resizeImage(:,:,2);
B = resizeImage(:,:,3);
y=imshow(image);
int(sym('low'));
int(sym('high'));
for i=60:1:119
for j=0:1:159
if((R(i,j)<=0) && R(i,j)<=52 && (G(i,j)<=0) && G(i,j)<=52 && (B(i,j)<=0) && B(i,j)<=52)
low=low+1;
else
high=high+1;
end
end
end
if((high < low))
display('man')
else
display ('women')
end
it keeps giving me this error . ."Subscript indices must either be real positive integers or logicals." on the if loop . .please help me out!! . . submission date is quite close!!
0 个评论
回答(1 个)
Image Analyst
2013-12-19
You can't start j out at 0. MATLAB is one based.
Don't use image as the name of your image variable. image() is a built-in function, so don't use it as a variable name. Also switch the order of your for loops to increase speed:
[rows, columns, numberOfColorChannels] = size(rgbImage);
for col = 1 : columns
for row = 60 : 119
if R(row, column) .........
or better yet, just get rid of the for loops and vectorize the thing:
lowMask = (R<=0) && R<=52 && (G<=0) && G<=52 && (B<=0) && B<=52)
low = sum(lowMask(:))
high = rows * columns - low;
2 个评论
Image Analyst
2013-12-19
By the way, what do men without beards think of your code that classifies them as women?
Walter Roberson
2016-6-21
For that matter, what do the women with beards think of your code that classifies them as men? (The women with beards that I have personally met have detested their beards but kept them for family or job reasons, but I have communicated with or read about other women who were happy with their beards.)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Import and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!