code for gender classification using mallab:ERROR

1 visualizzazione (ultimi 30 giorni)
mustafa
mustafa il 19 Dic 2013
Commentato: Walter Roberson il 21 Giu 2016
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!!

Risposte (1)

Image Analyst
Image Analyst il 19 Dic 2013
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 Commenti
Image Analyst
Image Analyst il 19 Dic 2013
By the way, what do men without beards think of your code that classifies them as women?
Walter Roberson
Walter Roberson il 21 Giu 2016
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.)

Accedi per commentare.

Categorie

Scopri di più su Data Import and Analysis in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by