Summary: This test determines whether a fish is a salmon or a trout based on the detection of the number of fins it has using the 1-D DWT
Fin testing Image![]() Figure 1: The binary fish image before the derivative is taken and the edges of the fins located. |
% This function looks through a grayscale version of the input rgb image and
% tries to detect fins by looking at each line of the picture and looking for
% where the data starts and stops.
function [fins] = findet(image);
grayimage = rgb2gray(image);
[wide, length] = size(grayimage);
Mass = 0;
n = 1;
frontedge = zeros(1,(length/2 -1));
backedge = zeros(1,(length/2 -1));
for i = 1:wide
tempfishrow = dwt(grayimage(i, :),'haar');
fishrow(i,:) = double(tempfishrow);
if sum(fishrow(i,:)) <= 0.9
Mass = Mass;
else
n = n + 1;
Mass = 1 + Mass;
fishrow(i,:) = fishrow(i,:) > 0;
diffrow(i,:) = diff(fishrow(i,:));
for j = 1:(length/2 - 1)
if diffrow(i,j) == 1
frontedge(1,j) = frontedge(1,j) + 1;
elseif diffrow(i,j) == -1
backedge(1,j) = backedge(1,j) + 1;
end
end
end
end
frontedgefilter = frontedge >=10;
frontedgeextreme = frontedge >=11;
backedge = backedge >=3;
for i = 1:(length/2 -1)
if frontedgefilter(1,i) == 1
if sum(frontedgefilter(1, i:i+10)) > 1
frontedgefilter(1, i:i+10) = [1 0 0 0 0 0 0 0 0 0 0];
end
end
end
fins = sum(frontedgefilter) - 1;