91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

MATLAB代碼,實現(xiàn)背景減除目標(biāo)檢測,并判斷魚頭朝向,魚頭截取

資源截圖

代碼片段和文件信息

function?[ZnumOfFishes]?=?video2Z(videograyThresholdareaThresholdhandles)
????seqName?=?handles.seqName;
????load([seqName‘/‘seqName‘_background.mat‘]‘background‘);
????background?=?double(background);
????
????totalframes?=?video.NumberOfframes;
????tam?=?[video.Heightvideo.Width];
????X?=?repmat(1:tam(2)[tam(1)?1]);%處理大矩陣:以1:tam(2)的矩陣內(nèi)容堆疊在[tam(1)?1]中,最終矩陣大小1*tam(1):tam(2)*1
????Y?=?repmat((1:tam(1))‘[1?tam(2)]);
????
????%?alloct?space
????Z?=?struct(‘centerCoor‘[]‘imageCroped‘[]);
????Z(1totalframes).centerCoor?=?[];
????numOfFishes?=?0;
????
%?????folder?=?‘OriginalPic‘;
%?????if?~exist(folder‘dir‘)
%?????????dos([‘mkdir?‘folder]);
%?????end
????meanValue?=?[];
????for?frame_act=1:totalframes?%num
????????set(handles.txtInfo‘String‘[‘video2Z:??‘?num2str(frame_act)?‘/‘?num2str(totalframes)]);
%?????????disp([‘video2Z:??‘?num2str(frame_act)?‘/‘?num2str(totalframes)]);
????????frame=read(videoframe_act);
????????if?size(frame3)==3
????????????frame?=rgb2gray(frame);
????????end
????????if?isempty(meanValue)
????????????meanValue?=?mean(mean(frame));
????????end
????????frame(frame>meanValue?+?10)?=?meanValue?+?10;
????????
????????frame_doub=double(frame);?%視頻大小
????????imgFilter2D=abs(frame_doub-background)>grayThreshold;%灰度閾值
????????
????????%?橢圓擬合
????????manchas=bwconncomp(imgFilter2D);?%背景減除算法得到目標(biāo)數(shù)量
????????tams=cellfun(@(x)?length(x)manchas.PixelIdxList);%求元胞數(shù)組manchas.PixelIdxList每個元胞的長度:length(x)
????????%?篩選面積大于?areaThreshold?的部分
????????listapixels=manchas.PixelIdxList(tams?>?areaThreshold);
????????

????????if?length(listapixels)>numOfFishes
????????????numOfFishes?=?length(listapixels);
????????end
????????
????????for?c_buenos=1:length(listapixels)

????????????imgFilter2D=false(manchas.ImageSize);%生成邏輯0矩陣
????????????imgFilter2D(listapixels{c_buenos})=true;%返回值為1
%?????????????ind=find(imgFilter2D);???????%返回非零元素所在位置
????????????x?=?X(imgFilter2D);
????????????y?=?Y(imgFilter2D);
????????????lim=[min(x)?max(x)?min(y)?max(y)];

????????????
????????????[coorXcoorY~~thetaaxisLongaxisShort]=minOuterRect(imgFilter2D0);
????????????Z(frame_act).centerCoor(:c_buenos)=?[sum(coorX(1:4:))/4sum(coorY(1:4:))/4];?????%?中心坐標(biāo)
????????????if?axisLong/axisShort?>3
????????????????%%?計算魚頭的方向
????????????????[nRownCol~]?=?

評論

共有 條評論