0

我正在使用视频分析对鱼类游泳进行研究,然后我需要仔细处理图像(从视频帧中获得),重点放在尾部。

这些图像是高分辨率的,我自定义的软件适用于二进制图像,因为它很容易使用数学运算。

为了获得这个二进制图像,我使用了 2 种方法:

1)将图像转换为灰色,反转颜色,然后转换为 bw,最后转换为具有阈值的二进制,这给了我这样的图像,几乎没有噪音。图像有时会丢失一些区域,并且与尾部不完全一致(现在我需要更多的准确性来确定尾部移动的幅度) 图像 1

2)我使用这个代码,用于切割增加阈值的边界,这给了我一个很好的边缘图像,但我不知道像联合这些点并平滑图像,或拟合二进制图像,matlab 2012Rb的应用程序拟合没有给我一个好的图表,我也无法访问 matlab 的工具箱。

s4 = imread('arecorte.bmp');
A=[90 90 1110 550]
s5=imcrop(s4,A)
E = edge(s5,'canny',0.59);

图2

我的问题是

我如何拟合二值图像或连接点并平滑而不干扰尾部?

或者我如何使用图像 2 的边缘来增加图像 1 的准确性?

我将在评论中上传一张图片,让我了解方法 2),因为我无法发布更多链接,请记住我正在使用迭代,我无法逐帧工作。

注意:如果我问这是因为我处于死角并且我没有资源支付给某人这样做,直到此刻我能够编写代码但在最后一个问题中我不能孤单.

4

1 回答 1

0

我认为您应该使用连接组件标签并丢弃小标签,然后提取标签边界以获取每个部分的像素

编码:

clear all

% Read image
I = imread('fish.jpg');

% You don't need to do it you haef allready a bw image
Ibw = rgb2gray(I); 
Ibw(Ibw < 100) = 0;

% Find size of image
[row,col] = size(Ibw);

% Find connceted components
CC = bwconncomp(Ibw,8);

% Find area of the compoennts
stats = regionprops(CC,'Area','PixelIdxList');
areas = [stats.Area];

% Sort the areas
[val,index] = sort(areas,'descend');

% Take the two largest comonents ids and create filterd image
IbwFilterd = zeros(row,col);
IbwFilterd(stats(index(1,1)).PixelIdxList) = 1;
IbwFilterd(stats(index(1,2)).PixelIdxList) = 1;
imshow(IbwFilterd);

% Find the pixels of the border of the main component and tail
boundries = bwboundaries(IbwFilterd);

yCorrdainteOfMainFishBody = boundries{1}(:,1);
xCorrdainteOfMainFishBody = boundries{1}(:,2);
linearCorrdMainFishBody = sub2ind([row,col],yCorrdainteOfMainFishBody,xCorrdainteOfMainFishBody);

yCorrdainteOfTailFishBody = boundries{2}(:,1);
xCorrdainteOfTailFishBody = boundries{2}(:,2);
linearCorrdTailFishBody = sub2ind([row,col],yCorrdainteOfTailFishBody,xCorrdainteOfTailFishBody);

% For visoulaztion put color for the boundries
IFinal = zeros(row,col,3);
IFinalChannel = zeros(row,col);

IFinal(:,:,1) = IFinalChannel;

IFinalChannel(linearCorrdMainFishBody) = 255;
IFinal(:,:,2) = IFinalChannel;

IFinalChannel = zeros(row,col);
IFinalChannel(linearCorrdTailFishBody) = 125;
IFinal(:,:,3) = IFinalChannel;
imshow(IFinal);

最终图像: 在此处输入图像描述

于 2016-09-13T19:32:09.243 回答