欧美色欧美亚洲高清在线观看,国产特黄特色a级在线视频,国产一区视频一区欧美,亚洲成a 人在线观看中文

  1. <ul id="fwlom"></ul>

    <object id="fwlom"></object>

    <span id="fwlom"></span><dfn id="fwlom"></dfn>

      <object id="fwlom"></object>

      matlab圖像處理小結(jié)

      時間:2019-05-12 04:05:39下載本文作者:會員上傳
      簡介:寫寫幫文庫小編為你整理了多篇相關(guān)的《matlab圖像處理小結(jié)》,但愿對你工作學(xué)習(xí)有幫助,當(dāng)然你在寫寫幫文庫還可以找到更多《matlab圖像處理小結(jié)》。

      第一篇:matlab圖像處理小結(jié)

      1.function [center, r] = solve_circle(pt1, pt2, pt3)

      2.%Effect: solve the circle which across points 'pt1', 'pt2' and 'pt3' 3.%Inputs:

      4.%pt1, pt2, pt3: [x, y]

      5.%center: the circle center [x0;y0] 6.%r: the radius of the circle 7.%Author: Su dongcai at 2012/1/2 8.A = zeros(2, 2);B = zeros(2, 1);9.[A(1, :), B(1)] = circle2line(pt1, pt2);10.[A(2, :), B(2)] = circle2line(pt2, pt3);11.center = AB;

      12.r = norm(pt1'(y2^2 + y2^2)18.%(a-x2)^2 +(b-y2)^2 = r^2 | 19.%Inputs:

      20.%pt1, pt2: [x1, y1], [x2, y2] 21.%Outputs:

      22.%A: 2[x1-x2, y1-y2]

      23.%B:(x1^2 + y1^2)pt2);

      26.B = norm(pt1)^2-norm(pt2)^2;

      close all;clear;clc;>> i=imread('rice.png');%>> imshow(i);>> background=imopen(i,strel('disk',15));>> i2=imsubtract(i,background);%>> figure,imshow(i2);>> i3=imadjust(i2,stretchlim(i2),[0 1]);%>> figure,imshow(i3);>> level=graythresh(i3);>> bw=im2bw(i3,level);%>> figure,imshow(bw);>> [labeled,numobjects]=bwlabel(bw,4);graindata=regionprops(labeled,'all');

      close all;clear;clc;i=imread('rice.png');background=imopen(i,strel('disk',15));i2=imsubtract(i,background);i3=imadjust(i2,stretchlim(i2),[0 1]);level=graythresh(i3);bw=im2bw(i3,level);[labeled,numobjects]=bwlabel(bw,4);data=regionprops(labeled,'all');

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %2006.6.2 close all;clear;clc;>> i=imread('r.jpg');%>> figure,imshow(i);>> imgray=rgb2gray(i);>> figure,imshow(imgray)>> background=imopen(imgray,strel('disk',15));>> i2=imsubtract(imgray,background);%>> figure,imshow(i2);>> i3=imadjust(i2,stretchlim(i2),[0 1]);%>> figure,imshow(i3);>> level=graythresh(i3);>> bw=im2bw(i3,level);%>> figure,imshow(bw);>> imnobord=imclearborder(bw,4);%>> figure,imshow(imnobord);>> [labeled,numobjects]=bwlabel(bw,4);>> rgb_label=label2rgb(labeled,@spring,'c','shuffle');>> figure,imshow(rgb_label);>> graindata=regionprops(labeled,'all');hold on;for k=1:numobjects lab=sprintf('%d',k);text(graindata(k).Centroid(1),graindata(k).Centroid(2),lab,'Color','k');end hold off;%剔除碎米粒

      >> idxdown=find([graindata.Area]<150);%剔除碎米粒 little=ismember(labeled,idxdown);figure,imshow(little);

      [lab_little,num_little]=bwlabel(little,4);rgb_little=label2rgb(lab_little,@spring,'c','shuffle');figure,imshow(rgb_little);

      little_data=regionprops(lab_little,'all');hold on;for k=1:num_little lab=sprintf('%d',k);text(little_data(k).Centroid(1),little_data(k).Centroid(2),lab,'Color','k');end hold off;%>> graindata(idxdown,:)=[];%剔除碎米粒 %剔除連接米粒

      >> idxup=find([graindata.Area]>250);%剔除連接米粒 big=ismember(labeled,idxup);figure,imshow(big);

      [lab_big,num_big]=bwlabel(big,4);rgb_big=label2rgb(lab_big,@spring,'c','shuffle');figure,imshow(rgb_big);

      big_data=regionprops(lab_big,'all');hold on;for k=1:num_big lab=sprintf('%d',k);text(big_data(k).Centroid(1),big_data(k).Centroid(2),lab,'Color','k');end hold off;%>> graindata(numup,:)=[];%剔除連接米粒 %獲取完整米粒

      idxsuit=find([graindata.Area]>=150&[graindata.Area]<=250);suit=ismember(labeled,idxsuit);figure,imshow(suit);%獲取完整米粒 [lab_suit,num_suit]=bwlabel(suit,4);suit_data=regionprops(lab_suit,'all');hold on;for k=1:num_suit signature=sprintf('%d',k);text(suit_data(k).Centroid(1),suit_data(k).Centroid(2),signature,'Color','r');end hold off;%獲取完整米粒 whos graindata whos little_data whos big_data whos suit_data

      >> graindata >> mean([graindata.Area])>> mean([graindata.Eccentricity])>> mean([graindata.MajorAxisLength])>> mean([graindata.MinorAxisLength])>> mean([graindata.EquivDiameter])>> figure,hist([graindata.Area],20);>> figure,hist([graindata.Eccentricity],20);>> figure,hist([graindata.MajorAxisLength],20);>> figure,hist([graindata.MinorAxisLength],20);>> figure,hist([graindata.EquivDiameter],20);

      data=[graindata.Area] data=[graindata.Centroid] data=[graindata.BoundingBox] data=[graindata.SubarrayIdx] data=[graindata.MajorAxisLength] data=[graindata.MinorAxisLength] data=[graindata.Eccentricity] data=[graindata.Orientation] data=[graindata.ConvexHull] data=[graindata.ConvexImage] data=[graindata.ConvexArea] data=[graindata.Image] data=[graindata.FilledImage] data=[graindata.FilledArea] data=[graindata.EulerNumber] data=[graindata.Extrema] data=[graindata.EquivDiameter] data=[graindata.Solidity] data=[graindata.Extent] data=[graindata.PixelIdxList] data=[graindata.PixelList]

      Area 計算各個連通區(qū)域中的象素總數(shù) BoundingBox 包含相應(yīng)區(qū)域的最小矩形 Centroid 給出每個區(qū)域的質(zhì)心

      MajorAxisLength 與區(qū)域具有相同標(biāo)準(zhǔn)二階中心矩(又叫標(biāo)準(zhǔn)差)的橢圓的長軸長度 MinorAxisLength 與區(qū)域具有相同標(biāo)準(zhǔn)二階中心矩的橢圓的短軸長度 Eccentricity 與區(qū)域具有相同標(biāo)準(zhǔn)二階中心矩的橢圓的離心率

      Orientation 與區(qū)域具有相同標(biāo)準(zhǔn)二階中心矩的橢圓的長軸與x軸的交角 Image 二值圖像,與某區(qū)域具有相同大小的邏輯矩陣。

      FilledImage 與上相同,唯一區(qū)別是這是個做了填充的邏輯矩陣!本例中和上面的沒有區(qū)別,只有 區(qū)域有空洞時才有明顯差別。

      FilledArea 是標(biāo)量,填充區(qū)域圖像中的 on 像素個數(shù)

      ConvexHull 是p行2列的矩陣,包含某區(qū)域的最小凸多邊形 ConvexImage 二值圖像,用來畫出上述的區(qū)域最小凸多邊形 ConvexArea 是標(biāo)量,填充區(qū)域凸多邊形圖像中的 on 像素個數(shù) EulerNumber 等于圖像中目標(biāo)個數(shù)減去這些目標(biāo)中空洞的個數(shù) Extrema 8行2列矩陣,八方向區(qū)域極值點

      EquivDiameter 是標(biāo)量,等價直徑:與區(qū)域具有相同面積的圓的直徑.計算公式為:sqrt(4*Area/pi)

      Solidity 是標(biāo)量,同時在區(qū)域和其最小凸多邊形中的像素比例。計算公式為: Area/ConvexArea,這也是個仿射特征,實際上反映出區(qū)域的固靠性程度。

      Extent 是標(biāo)量,同時在區(qū)域和其最小邊界矩形中的像素比例。計算公式為:Area除以邊界矩 形面積,這也是個仿射特征,實際上反映出區(qū)域的擴展范圍程度。

      PixelIdxList p元向量,存儲區(qū)域像素的索引下標(biāo)

      PixelList p行ndims(L)列矩陣,存儲上述索引對應(yīng)的像素坐標(biāo) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 基于特定原則的區(qū)域選擇

      當(dāng)你要基于特定準(zhǔn)則條件選擇某個區(qū)域時,將函數(shù) ismember 和 regionprops 聯(lián)合使用是很有用處的。例如:創(chuàng)建一個只包含面積大于80的二值圖像,用以下命令

      idx = find([stats.Area] > 80);BW2 = ismember(L,idx);regionprops函數(shù)的擴展思路

      在regionprops函數(shù)的基礎(chǔ)上,你可以使用它提供的基本數(shù)據(jù)來擴展它的功能,比如我就將區(qū)域的曲率數(shù)據(jù)和骨架數(shù)據(jù)作為它的另外屬性值來開發(fā),從而希望它能用來做更細(xì)致的特征提取。

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %2006.6.2 P221圖像粒度測定(雪花)>> i=imread('snowflakes.png');>> figure,imshow(i);>> %(2)>> clahei=adapthisteq(i,'numtiles',[10 10]);>> clahei=imadjust(clahei);>> imshow(clahei);>> gi=imadjust(im2double(i),[],[0 1]);>> figure,imshow(gi),title('adjusted grayscale image');>> %(3)>> se=strel('disk',10);>> topi=imtophat(gi,se);>> figure,imshow(topi),title('top-hat image');>> %(4)>> for counter=0:22 remain=imopen(clahei,strel('disk',counter));intensity_area(counter+1)=sum(remain(:));end >> figure,plot(intensity_area,'m-*'),grid on;>> title('sum of opening(pixels)');>> title('sum of opening values in opened image as a function of radius');>> xlabel('radius of opening(pixels)');>> ylabel('pixel value sum of opened objects(intensity)');>> >> >> >> for counter=0:20 remain=imopen(topi,strel('disk',counter));surfarea(counter+1)=sum(remain(:));end >> figure,plot(surfarea,'m-*'),grid on;>> set(gca,'xtick',[0 2 4 6 8 10 12 14 16 18 20]);>> title('surface area of opened objects as a function of radius');>> xlabel('radius of opening(pixels)');>> ylabel('surface area of opened objects(pixels)');>> %(5)>> intensity_area_prime=diff(intensity_area);>> figure,plot(intensity_area_prime,'m-*'),grid on;>> title('Granulometry(size distrubution)of snowflakes');>> set(gca,'xtick',[0 2 4 6 8 10 12 14 16 18 20 22]);>> xlabel('radius of snowflakes(pixels)');>> ylabel('sum of pixel values in snowflakes as a function of radius');>> derivsurfarea=diff(surfarea);>> figure,plot(derivsurfarea,'m-*'),grid on;>> title('granulometry(size distribution)of stars');>> xlabel('radius of stars(pixels)');>> ylabel('loss of pixels between two successive openings');

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %2006.6.2 花椒檢測 clc;clear;close all;i=imread('gj.jpg');imshow(i);icanny=edge(i,'canny');imshow(icanny);se90=strel('line',2,90);se0=strel('line',2,0);bwsdil=imdilate(icanny,[se90 se0]);figure,imshow(bwsdil),title('dilated');ifill=imfill(bwsdil,'holes');figure,imshow(ifill);

      %bwero=imerode(bwsdil,[se90 se0]);%figure,imshow(bwero);%i2fill=imfill(bwero,'holes');%figure,imshow(bwero);%imshow(i2fill);

      %bwnobord=imclearborder(bwsdil,4);%figure,imshow(bwnobord);bwnobord=imclearborder(ifill,4);figure,imshow(bwnobord);se=strel('disk',5);bwc=imclose(bwnobord,se);bwco=imopen(bwnobord,se);figure,imshow(bwc);figure,imshow(bwco);%mask=bwsdil&bwco;%figure,imshow(mask);clc [labeled,numobjects]=bwlabel(bwco);numobjects

      jdata=regionprops(labeled,'all');%jdata

      jarea=[jdata.Area];mean(jarea)max(jarea)min(jarea)hist(jarea,255)jdata.Eccentricity %std([jdata.Eccentricity])/(Mean([jdata.Eccentricity])jstd=std([jdata.Eccentricity])jmean=Mean([jdata.Eccentricity])jcv=jstd/jmean

      >> std([jdata.Area])/ mean([jdata.Area])%面積的變異系數(shù)

      >> std([jdata.Eccentricity])/ mean([jdata.Eccentricity])%橢圓的變異系數(shù) >> std([jdata.MajorAxisLength])/ mean([jdata.MajorAxisLength])>> std([jdata.MinorAxisLength])/ mean([jdata.MinorAxisLength])>> std([jdata.EquivDiameter])/ mean([jdata.EquivDiameter])

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %2006.06.06 rice.png close all;clear;clc >> i=imread('rice.png');imshow(i);background=imopen(i,strel('disk',15));figure,imshow(background);i2=imsubtract(i,background);figure,imshow(i2);i3=imadjust(i2,stretchlim(i2),[0 1]);figure,imshow(i3);level=graythresh(i3);bw=im2bw(i3,level);figure,imshow(bw);imnobord=imclearborder(bw);[label,numobjects]=bwlabel(imnobord,4);numobjects rgb_label=label2rgb(label,@spring,'c','shuffle');figure,imshow(rgb_label);graindata=regionprops(label,'all');graindata

      >> numdown=find([graindata.Area]<150);>> graindata(numdown,:)=[];>> numup=find([graindata.Area]>250);>> graindata(numup,:)=[];>> graindata

      >> std([graindata.Area])/ mean([graindata.Area])%面積的變異系數(shù)

      >> std([graindata.Eccentricity])/ mean([graindata.Eccentricity])%橢圓的變異系數(shù)

      >> std([graindata.MajorAxisLength])/ mean([graindata.MajorAxisLength])>> std([graindata.MinorAxisLength])/ mean([graindata.MinorAxisLength])>> std([graindata.EquivDiameter])/ mean([graindata.EquivDiameter])%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %2006.06.06 rice的堊白度檢測 >> clear;close all;clc;>> rgb=imread('r.jpg');>> close all;>> imshow(rgb);>> i=rgb2gray(rgb);>> j=medfilt2(i,[5 5]);>> figure,imshow(i);>> figure,imshow(j);>> imhist(j,256);>> t=0.3;>> v=imadjust(j,[t 1],[],1);>> imhist(v,256);>> t_c=0.6;>> bw_v=im2bw(v,0.01);>> chalk=imadjust(v,[t_c 1],[],1);>> bw_chalk=im2bw(chalk,0.01);>> figure,imshow(v);>> figure,imshow(bw_v);>> figure,imshow(chalk);>> figure,imshow(bw_chalk);>> degree_chalkness=bwarea(bw_chalk)/bwarea(bw_v)*100 >> bw=im2bw(j,t);>> figure,imshow(bw);>> se=(ones(3,3));>> bw1=imerode(bw,se);%兩次腐蝕 >> figure,imshow(bw1);>> bw2=imerode(bw1,se);>> figure,imshow(bw2);

      >> [l,num]=bwlabel(bw2);%標(biāo)記腐蝕后的大米圖像 >> t_chalk=100;%設(shè)置堊白面積的下限 >> compare=(l)&(chalk>t_chalk);%>> compare=(bw2)&(bw_chalk>t_chalk);>> [r,c]=find(compare);%標(biāo)記堊白米粒的位置 >> result=bwselect(l,c,r);%顯示只含有堊白米粒的圖像 >> figure,imshow(result);

      >> [l_chalk,num_chalk]=bwlabel(result);%標(biāo)記堊白米粒圖像,便于計數(shù) >> rate_chalky_grains=num_chalk/num*100;>> rate_chalky_grains

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %2006.6.17 bwmorph函數(shù) >> help bwmorph BWMORPH Perform morphological operations on binary image.BW2 = BWMORPH(BW1,OPERATION)applies a specific morphological operation to the binary image BW1.BW2 = BWMORPH(BW1,OPERATION,N)applies the operation N times.N can be Inf, in which case the operation is repeated until the image no longer changes.OPERATION is a string that can have one of these values: 'bothat' Subtract the input image from its closing 'bridge' Bridge previously unconnected pixels 'clean' Remove isolated pixels(1's surrounded by 0's)'close' Perform binary closure(dilation followed by erosion)'diag' Diagonal fill to eliminate 8-connectivity of background 'dilate' Perform dilation using the structuring element ones(3)'erode' Perform erosion using the structuring element ones(3)'fill' Fill isolated interior pixels(0's surrounded by 1's)'hbreak' Remove H-connected pixels 'majority' Set a pixel to 1 if five or more pixels in its 3-by-3 neighborhood are 1's 'open' Perform binary opening(erosion followed by dilation)'remove' Set a pixel to 0 if its 4-connected neighbors are all 1's, thus leaving only boundary pixels 'shrink' With N = Inf, shrink objects to points;shrink objects with holes to connected rings 'skel' With N = Inf, remove pixels on the boundaries of objects without allowing objects to break apart 'spur' Remove end points of lines without removing small objects completely.'thicken' With N = Inf, thicken objects by adding pixels to the exterior of objects without connected previously unconnected objects 'thin' With N = Inf, remove pixels so that an object without holes shrinks to a minimally connected stroke, and an object with holes shrinks to a ring halfway between the hold and outer boundary 'tophat' Subtract the opening from the input image

      Class Support-------------The input image BW1 can be numeric or logical.It must be 2-D, real and nonsparse.The output image BW2 is logical.Examples--------BW1 = imread('circles.png');imview(BW1)BW2 = bwmorph(BW1,'remove');BW3 = bwmorph(BW1,'skel',Inf);imview(BW2)imview(BW3)

      See also erode, dilate, bweuler, bwperim.Reference page in Help browser doc bwmorph

      BW1 = imread('circles.png');figure,imshow(BW1)BW2 = bwmorph(BW1,'erode');figure,imshow(BW2)

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %邊界提取 b=bwmorph(bw,'remove');b=bwperim(bw,8);%又叫邊界象素測定 b=edge(bw,'canny');%又叫邊界提取 %去除孤立象素點

      nosinglepixel=bwmorph(bw,'clean');%去除小面積物體

      nosmall=bwareaopen(bw,CNN);%閾值處理再取反

      bw=~im2bw(i,graythresh(i));

      %開運算(消除小物體)與閉運算(填充物體內(nèi)細(xì)小空洞)se=strel('disk',6);iopen=imopen(bw,se);iclose=imclose(bw,se);%腐蝕與膨脹聯(lián)合操作 %(1)創(chuàng)建結(jié)構(gòu)元素 se=strel('rectangle',[40 30]);%(2)使用結(jié)構(gòu)元素腐蝕圖像 bw1=imread('circbw.tif');bw2=imerode(bw1,se);imshow(bw2);%(3)逆操作,回復(fù)矩形原來大小 bw3=imdilate(bw2,se);figure,imshow(bw3);

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %2006.6.18花椒子

      %直接對灰度圖進(jìn)行canny運算 >> i=imread('nut.bmp');>> figure,imshow(i);>> ig=rgb2gray(i);>> figure,imshow(ig);%igcanny=edge(ig,'canny');%igcfill=imfill(igcanny,'hole');igcanny_thresh=edge(ig,'canny',(graythresh(ig)*.1));igcfill=imfill(igcanny_thresh,'hole');>> figure,imshow(igcfill);

      %先對灰度圖濾波,再進(jìn)行canny運算

      >> imed=medfilt2(ig);%中值濾波后對圖像邊界有一定的損傷?。?> imedcanny=edge(imed,'canny');>> imedfill=imfill(imedcanny,'hole');>> figure,imshow(imedfill);>> nosmall=bwareaopen(imedfill,150);>> figure,imshow(nosmall);

      %注意:若對灰度圖像先拉氏銳化,在canny提取邊界,效果不大好?。?結(jié)論:無需拉氏銳化,也不必中值濾波,可直接canny提取邊界??!>> ifill=igcfill|imedfill;>> figure,imshow(ifill);>> nosmall=bwareaopen(ifill,150);>> figure,imshow(nosmall);

      %當(dāng)t=0.55時,閾值處理再canny運算的效果 >> imhist(ig);>> t=0.55;>> v=imadjust(ig,[0 t],[],1);>> vcanny=edge(v,'canny');>> vfill=imfill(vcanny,'hole');>> figure,imshow(vfill);>> ifill=igcfill|vfill;>> figure,imshow(ifill);>> nosmall=bwareaopen(ifill,150);>> figure,imshow(nosmall);

      %當(dāng)t=0.6時,閾值處理再canny運算的效果的效果 >> t=0.6;>> v=imadjust(ig,[0 t],[],1);>> vcanny=edge(v,'canny');>> vfill=imfill(vcanny,'hole');>> figure,imshow(vfill);>> ifill=igcfill|vfill;>> figure,imshow(ifill);>> nosmall=bwareaopen(ifill,150);>> figure,imshow(nosmall);

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %處理花椒子

      >> i=imread('nut.bmp');%figure,imshow(i);ig=rgb2gray(i);figure,imshow(ig);>> imed=medfilt2(ig);imedcanny=edge(imed,'canny');imedfill=imfill(imedcanny,'hole');%figure,imshow(imedfill);nosmall=bwareaopen(imedfill,150);>> figure,imshow(nosmall);>> [labeled,numobjects]=bwlabel(nosmall,4);>> rgb_label=label2rgb(labeled,@spring,'c','shuffle');%>> figure,imshow(rgb_label);>> nutdata=regionprops(labeled,'all');>> min([nutdata.Solidity])

      >> rectangle('Position', [253.5000 207.5000 26.0000 28.0000])%畫矩形

      >> rectangle('Position', [250.5000 50.5000 27.0000 26.0000])>> figure,imshow(nutdata(1).Image)%只顯示1號物體的圖像

      >> figure,imshow(nutdata(1).ConvexImage)%畫出1號物體的凸多邊形 >> std([nutdata.Eccentricity])/ mean([nutdata.Eccentricity])std([nutdata.Area])/ mean([nutdata.Area])std([nutdata.Solidity])/ mean([nutdata.Solidity])>> std([nutdata.Centroid])/ mean([nutdata.Centroid])std([nutdata.MajorAxisLength])/ mean([nutdata.MajorAxisLength])std([nutdata.MinorAxisLength])/ mean([nutdata.MinorAxisLength])std([nutdata.Orientation])/ mean([nutdata.Orientation])std([nutdata.EquivDiameter])/ mean([nutdata.EquivDiameter])std([nutdata.Extent])/ mean([nutdata.Extent])std([nutdata.Extrema])/ mean([nutdata.Extrema])

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %處理花椒皮 close all;clc;clear;>> i=imread('p.bmp');imshow(i);ig=rgb2gray(i);figure,imshow(ig);imed=medfilt2(ig);imedcanny=edge(imed,'canny');figure,imshow(imedcanny);>> se90=strel('line',2,90);se0=strel('line',2,0);bwsdil=imdilate(imedcanny,[se90 se0]);figure,imshow(bwsdil),title('dilated');ifill=imfill(bwsdil,'holes');figure,imshow(ifill);>> bwero=imerode(ifill,[se90 se0]);>> figure,imshow(bwero);>> nosmall=bwareaopen(bwero,150,4);>> figure,imshow(nosmall);>> nobord=imclearborder(nosmall,4);>> figure,imshow(nobord);>> [labeled,numobjects]=bwlabel(nobord,4);>> numobjects >> pdata=regionprops(labeled,'all');>> max([pdata.Solidity])>> std([pdata.Solidity])/mean([pdata.Solidity])

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %處理混合圖像 >> clear;clc;close all;>> i=imread('m.bmp');%>> figure,imshow(i);>> ig=rgb2gray(i);figure,imshow(ig);imed=medfilt2(ig);%>> figure,imshow(imed);imedcanny=edge(imed,'canny');%>> figure,imshow(imedcanny);>> se90=strel('line',2,90);se0=strel('line',2,0);bwsdil=imdilate(imedcanny,[se90 se0]);%figure,imshow(bwsdil),title('dilated');ifill=imfill(bwsdil,'holes');%figure,imshow(ifill);bwero=imerode(ifill,[se90 se0]);%figure,imshow(bwero);>> nosmall=bwareaopen(bwero,150,4);%figure,imshow(nosmall);nobord=imclearborder(nosmall,4);figure,imshow(nobord);>> [labeled,numobjects]=bwlabel(nobord,4);>> numobjects >> rgb_label=label2rgb(labeled,@spring,'c','shuffle');figure,imshow(rgb_label);>> mexdata=regionprops(labeled,'all');hold on;%以下內(nèi)容畫在同一figure中 centr=[mexdata.Centroid];%尋找重心位置 nums=1:numobjects;for k = 1:numobjects soli=mexdata(k).Solidity;soli_string=sprintf('%2.2f',soli);%等價于轉(zhuǎn)字符串 % signal=num2str(nums(k));signal=sprintf('%d',k);%直接使用打印語句打印序號 text(centr(2*k-1),centr(2*k),signal)%按序標(biāo)記物體

      text(centr(2*k-1)-30,centr(2*k)-30,soli_string)%標(biāo)注每個Solidity值 end

      for k=1:numobjects plot(mexdata(k).ConvexHull(:,1),mexdata(k).ConvexHull(:,2),...'b','Linewidth',2)end

      %畫出1和2號物體的外接矩形

      %>> rectangle('position',[9.5000 224.5000 62.0000 63.0000])%>> rectangle('position',[65.5000 141.5000 34.0000 39.0000])%畫出每個物體的外接矩形 bb=[mexdata.BoundingBox];for k=1:numobjects rectangle('position',[bb(4*k-3)bb(4*k-2)bb(4*k-1)bb(4*k)])end

      %>> figure,imshow(mexdata(1).Image)%只顯示1號物體的圖像

      %>> figure,imshow(mexdata(1).ConvexImage)%畫出1號物體的凸多邊形 %>> figure,imshow(mexdata(2).Image)%只顯示2號物體的圖像

      %>> figure,imshow(mexdata(2).ConvexImage)%畫出2號物體的凸多邊形 %畫出單個物體的凸多邊形的填充圖形 for k=1:numobjects figure,imshow(mexdata(k).ConvexImage)end

      %只顯示Solidity>0.92的物體的圖像 >> idx = find([mexdata.Solidity] > 0.92);>> BW2 = ismember(labeled,idx);>> figure,imshow(BW2)

      >> mexdata=regionprops(labeled,'all');>> %只顯示Solidity<0.92的物體的圖像 idx = find([mexdata.Solidity] < 0.92);bw2 = ismember(labeled,idx);figure,imshow(bw2)%mexdata.Solidity;

      >> numdown=find([mexdata.Solidity]<0.92);mexdata(numdown,:)=[];>> mexdata

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %2006.6.19 %roipoly函數(shù)的用法 I = imread('eight.tif');c = [222 272 300 270 221 194];r = [21 21 75 121 121 75];BW = roipoly(I,c,r);imview(I), imview(BW)

      %可以使用下面的方法創(chuàng)建相應(yīng)的向量: regionprops(L,'Area');allArea = [stats.Area];

      %創(chuàng)建一個只包含面積大于80的二值圖像 idx = find([stats.Area] > 80);BW2 = ismember(L,idx);

      %只顯示某個下標(biāo)所對應(yīng)的物體圖像 bw2=ismember(L,N);figure,imshow(bw2);

      %在調(diào)用regionprops之前必須將二值圖像轉(zhuǎn)變?yōu)闃?biāo)注矩陣 L = bwlabel(BW);%或者

      L = double(BW);

      %將matlab數(shù)據(jù)寫到excel中 a=ones(3);success = xlswrite('c:/matlab/work/myworkbook.xls',a,'A2:C4')%將行矩陣轉(zhuǎn)換為列矩陣 a=[1 2 3 4 5 6];b=transpose(a);

      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %2006.6.22球形物體的檢測和標(biāo)識(循環(huán)檢測和標(biāo)識算法)clc;clear;close all;%Step 1: Read image %Step 2: Threshold the image %Step 3: Remove the noise %Step 4: Find the boundaries %Step 5: Determine which objects are round >> RGB = imread('pillsetc.png');imshow(RGB)>> I = rgb2gray(RGB);threshold = graythresh(I);bw = im2bw(I,threshold);imshow(bw)>> % remove all object containing fewer than 30 pixels bw = bwareaopen(bw,30);>> figure,imshow(bw)>> % fill a gap in the pen's cap se = strel('disk',2);bw = imclose(bw,se);>> figure,imshow(bw)>> % fill any holes, so that regionprops can be used to estimate % the area enclosed by each of the boundaries bw = imfill(bw,'holes');>> figure,imshow(bw)>> [B,L] = bwboundaries(bw,'noholes');>> % Display the label matrix and draw each boundary figure,imshow(label2rgb(L, @jet, [.5.5.5]))>> hold on for k = 1:length(B)boundary = B{k};plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2)end >> stats = regionprops(L,'Area','Centroid');>> stats = regionprops(L,'Area','Centroid');threshold = 0.94;% loop over the boundaries for k = 1:length(B)% obtain(X,Y)boundary coordinates corresponding to label 'k' boundary = B{k};% compute a simple estimate of the object's perimeter delta_sq = diff(boundary).^2;perimeter = sum(sqrt(sum(delta_sq,2)));

      % obtain the area calculation corresponding to label 'k' area = stats(k).Area;

      % compute the roundness metric metric = 4*pi*area/perimeter^2;

      % display the results metric_string = sprintf('%2.2f',metric);% mark objects above the threshold with a black circle if metric > threshold centroid = stats(k).Centroid;plot(centroid(1),centroid(2),'ko');end

      text(boundary(1,2)-35,boundary(1,1)+13,metric_string,'Color','y',...'FontSize',14,'FontWeight','bold');end >> title(['Metrics closer to 1 indicate that ',...'the object is approximately round']);

      第二篇:基于MATLAB圖像處理報告

      基于MATLAB圖像處理報告

      一、設(shè)計題目

      圖片疊加。

      二、設(shè)計要求

      將一幅禮花圖片和一幅夜景圖片做疊加運算,使達(dá)到煙花夜景的美圖效果。

      三、設(shè)計方案

      3.1、設(shè)計思路

      利用matlab強大的圖像處理功能,通過編寫程序,實現(xiàn)對兩幅圖片的像素進(jìn)行線性運算,利用灰度變換的算法使圖片達(dá)到預(yù)期的效果。

      3.2、軟件介紹

      MATLAB是matrix&laboratory兩個詞的組合,意為矩陣工廠(矩陣實驗室)。是由美國mathworks公司發(fā)布的主要面對科學(xué)計算、可視化以及交互式程序設(shè)計的高科技計算環(huán)境。它將數(shù)值分析、矩陣計算、科學(xué)數(shù)據(jù)可視化以及非線性動態(tài)系統(tǒng)的建模和仿真等諸多強大功能集成在一個易于使用的視窗環(huán)境中,為科學(xué)研究、工程設(shè)計以及必須進(jìn)行有效數(shù)值計算的眾多科學(xué)領(lǐng)域提供了一種全面的解決方案,并在很大程度上擺脫了傳統(tǒng)非交互式程序設(shè)計語言(如C、Fortran)的編輯模式,代表了當(dāng)今國際科學(xué)計算軟件的先進(jìn)水平。

      MATLAB和Mathematica、Maple并稱為三大數(shù)學(xué)軟件。它在數(shù)學(xué)類科技應(yīng)用軟件中在數(shù)值計算方面首屈一指。MATLAB可以進(jìn)行矩陣運算、繪制函數(shù)和數(shù)據(jù)、實現(xiàn)算法、創(chuàng)建用戶界面、連接其他編程語言的程序等,主要應(yīng)用于工程計算、控制設(shè)計、信號處理與通訊、圖像處理、信號檢測、金融建模設(shè)計與分析等領(lǐng)域。MATLAB的基本數(shù)據(jù)單位是矩陣,它的指令表達(dá)式與數(shù)學(xué)、工程中常用的形式十分相似,故用MATLAB來解算問題要比用C,F(xiàn)ORTRAN等語言完成相同的事情簡捷得多,并且MATLAB也吸收了像Maple等軟件的優(yōu)點,使MATLAB成為一個強大的數(shù)學(xué)軟件。在新的版本中也加入了對C,F(xiàn)ORTRAN,C++,JAVA的支持??梢灾苯诱{(diào)用,用戶也可以將自己編寫的實用程序?qū)氲組ATLAB函數(shù)庫中方便自己以后調(diào)用,此外許多的MATLAB愛好者都編寫了一些經(jīng)典的程序,用戶直接進(jìn)行下載就可以用。

      3.3、常見簡單程序語句及算法分析

      (1)CLC;清零。(2)CLEAR ; 清內(nèi)存。

      (3)r=imread(‘路徑圖片名.jpg’);讀入一幅圖片。(4)imshow(r);顯示圖片r。(5)g=rgb2gray(r);灰度轉(zhuǎn)變。

      (6)%imhist(g);g1=histeq(g);figure,imsho(g1);直方圖均衡化。(7)Imwrite(‘g1,路徑圖片名.jpg’);保存圖片。

      3.4、圖片疊加及灰度變換分析

      程序1 [m,n,l]=size(C);for i=1:m for j=1:n for k=1:l D(i,j,k)=C(i,j,k)+ B(i,j,k);end end end 此程序的主要功能是對兩幅圖片通過算法來實現(xiàn)疊加的效果,程序中的幾個變量都是像素點的值,通過三個循環(huán)使得兩幅圖片對應(yīng)的值線性相加,最大值應(yīng)該是以255輸出,超過255也是以255輸出。

      程序2 J = imadjust(I,[low_in high_in], [low_out high_out])此程序變換的原理是:如果原圖像f(x, y)的灰度范圍是[m, M],我們希望對圖像的灰度范圍進(jìn)行線性調(diào)整,調(diào)整后的圖像g(x, y)的灰度范圍是[n, N],那么下述變換:g(x,y)

      N

      n

      f(x,y)

      m

      n就可以實現(xiàn)這一要求。MATLAB圖像處理工具箱中提供的imadjust函數(shù),可以實現(xiàn)上述的線性變換對比度調(diào)整。

      四、設(shè)計步驟(1)處理之前,我們先來看看兩幅原圖,一幅是帶有禮花的圖片,另一幅是一幅東方明珠的夜景圖。

      圖 1

      圖 2 通過圖片我們發(fā)現(xiàn),禮花的圖片非常的亮,而夜景圖則顯得有些灰暗。我們推測,如果讓禮花和夜景的圖片疊加到一起,會不會由于禮花的亮度太大而掩蓋了城市的夜光,達(dá)不到我們想要的效果。

      (2)打開matlab圖像處理軟件,7.0及以上版本就可以,打開之后,顯示界面如下(我的版本是2012b)。

      圖3(3)新建script文件,點擊’New script‘,或點擊’New‘,選擇script。

      圖4(4)在打開的界面之中輸入程序。圖片的位置是你所要用的圖片的準(zhǔn)確位置,盡量寫詳細(xì)點,減少計算機的讀取時間,加快讀取速度。如圖所示。

      圖5(5)點擊運行按鈕,即界面上的綠色按鈕。

      圖6(6)查看效果,如下圖。

      圖7 通過處理后的圖片,我們看到由于禮花太亮,完全將城市的夜景掩蓋住了,效果不是太理想。我們設(shè)想加入灰度變換函數(shù),將禮花的圖片變的暗一點,將夜景的亮度提高一點,看看效果怎么樣,加入灰度變換程序,如下圖。

      圖8(7)軟件調(diào)試后運行程序,如下圖。

      圖9 結(jié)果顯示加入灰度變換的函數(shù)之后,圖片效果較之前好多了,達(dá)到了預(yù)期的目的。

      五、軟件代碼

      通過matlab進(jìn)行圖像處理,代碼如下: clear;clc;A=imread('C:UsersAdministratorDesktop作業(yè)禮花.jpg');C=imresize(A,[300,400]);B=imread('C:UsersAdministratorDesktop作業(yè)夜景提亮天空中加入禮花.jpg');[m,n,l]=size(C);for i=1:m for j=1:n for k=1:l D(i,j,k)=C(i,j,k)+ B(i,j,k);end end end figure imshow(D);imwrite('C:UsersAdministratorDesktop作業(yè)禮花效果圖1.jpg')調(diào)試之后的程序代碼如下: clear;clc;A=imread('C:UsersAdministratorDesktop作業(yè)禮花.jpg');B=imread('C:UsersAdministratorDesktop作業(yè)夜景提亮天空中加入禮花.jpg');A1=imadjust(A,[0,1],[0,0.9]);B1=imadjust(B,[0.3,0.6],[0,1]);C=imresize(A1,[300,400]);[m,n,l]=size(C);for i=1:m for j=1:n for k=1:l D(i,j,k)=C(i,j,k)+ B1(i,j,k);end end end figure imshow(D);imwrite('C:UsersAdministratorDesktop作業(yè)禮花效果圖2.jpg')處理后的圖片如下:

      圖 10

      六、結(jié)果分析

      通過兩幅圖的對比,發(fā)現(xiàn)第二幅圖片較第一幅,效果明顯增強。是由于加入灰度變換函數(shù),使原圖的灰度值發(fā)生變化,以達(dá)到實際的效果。

      效果對比圖11

      七、心得體會

      通過這次任務(wù),以前在課堂上沒太聽明白怎么回事的東西,通過上網(wǎng),查資料,以及用軟件處理,通通實踐了一遍,加深了對這門課程的認(rèn)識和理解。Matlab是一款功能很強大的應(yīng)用軟件,它不僅可以對圖像進(jìn)行處理,而且可以進(jìn)行各種數(shù)字計算和符號計算功能,具有繪圖功能,語言體系等等。這次的任務(wù)我們樂在其中,喜悅的是看到了成果,內(nèi)心充滿了滿足感和成就感,就如同看到了圖片中的煙花,有種過年的感覺。不過這些都只是皮毛而已,要想真正地掌握它,還得更進(jìn)一步地學(xué)習(xí)理論知識。

      參考文獻(xiàn):

      【岡薩雷斯 數(shù)字圖像處理(MATLAB版)】[美] RafaelC.Gonzalez RichardE.Woods StevenL.Eddins 著 電子工業(yè)出版社。

      【數(shù)字圖像處理及MATLAB實現(xiàn)】楊杰 主編 電子工業(yè)出版社。

      第三篇:Matlab圖像處理-圖像景物動態(tài)跟蹤

      《圖像處理技術(shù)》大作業(yè) 作業(yè)題目

      基于圖像的動態(tài)景物的監(jiān)測與跟蹤 作業(yè)數(shù)據(jù)

      (1)短視頻背景相同,一個目標(biāo)運動;(2)短視頻(或5張圖片),背景相同,多個目標(biāo)運動;(3)驗證數(shù)據(jù)自己提供(彩色、灰度圖像不限); 作業(yè)完成目標(biāo)

      動態(tài)目標(biāo)的定位與跟蹤,并用方框提示并給出運動軌跡 能正確檢測運動目標(biāo); 多個目標(biāo)的識別率;程序設(shè)計

      1、界面設(shè)計:

      2、“打開”按鈕功能設(shè)計:

      打開圖片組的第一張圖片并在左邊顯示:

      [name,path]=uigetfile('*.jpg;*.bmp;*.png;*.tif;*.gif','Open Image');file=[path,name];%讀取第一張圖片路徑 axes(handles.image1);%選擇在左窗口顯示 x=imread(file);%讀取第一張圖片 handles.img=x;guidata(hObject,handles);imshow(x);%顯示第一張圖片 global F;%全局變量F F=name(1:end-5);%F為文件名編號前的字符 global N;%全局變量N N=7;%N為圖片組中圖片總數(shù)量

      3、“播放”按鈕功能設(shè)計:

      讀取圖片組中所有的圖片,并按一定間隔時間顯示,形成動畫效果: global F;global N;axes(handles.image1);%選擇在左窗口顯示

      for i=1:N %循環(huán)讀出圖片,形成動畫效果 f=int2str(i);I=strcat(F,f,'.jpg');%聯(lián)接文件名 a=imread(I);%讀取圖片 imshow(a);%顯示圖片 axis off %關(guān)閉坐標(biāo)軸

      pause(0.8);%每顯示一張圖片暫停0.8秒 end

      4、“目標(biāo)追蹤”按鈕功能設(shè)計:

      讀取圖片,將圖片轉(zhuǎn)成二值圖像,利用兩張二值圖像的異或求得目標(biāo),在目標(biāo)圖像中求得目標(biāo)的邊框與質(zhì)心,利用求得的邊框畫出目標(biāo)的位置,利用存儲的質(zhì)心畫出目標(biāo)移動軌跡: global F;global N;x=handles.img;axes(handles.image2);%選擇在右窗口顯示 s=size(x);%獲取圖片大小 A=uint8(zeros(s(1),s(2),1,N));s=size(A);%獲取圖片組數(shù)組的大小 for i=1:s(4)%循環(huán)讀取圖片 t=int2str(i);I=strcat(F,t,'.jpg');a=imread(I);%讀取圖片

      A(:,:,:,i)=rgb2gray(a);%轉(zhuǎn)為灰度圖片 end B=logical(zeros(s(1),s(2),s(3),s(4)));%定義二值矩陣 for f=1:s(4)imshow(A(:,:,:,f));%顯示圖片

      level=graythresh(A(:,:,:,f))-30/255;%獲取閾值 B(:,:,:,f)=im2bw(A(:,:,:,f),level);%轉(zhuǎn)為二值圖像 B(:,:,:,1)=im2bw(A(:,:,:,1),level);B(:,:,:,f)= xor(B(:,:,:,1),B(:,:,:,f));%異或求得目標(biāo)區(qū)域 B(:,:,:,1)= xor(B(:,:,:,1),B(:,:,:,1));B(:,:,:,f)=medfilt2(B(:,:,:,f),[7 7]);%對二值圖像中值濾波

      L=bwlabel(B(:,:,:,f));%計算二值圖像的連通區(qū)域 stas=regionprops(L,'All');%獲取圖像連通區(qū)信息 t=size(stas);%獲取連通區(qū)數(shù)量 for j=1:t(1)p(f,j,:)=stas(j).BoundingBox;%存儲目標(biāo)邊框

      y(f,j,:)=stas(j).Centroid;%存儲目標(biāo)位子(質(zhì)心)%畫出目標(biāo)邊框

      rectangle('Position',p(f,j,:),'LineWidth',2,'LineStyle','--','EdgeColor','r');for k=1:f %以小方點畫出目標(biāo)軌跡

      rectangle('Position',[y(k,j,1),y(k,j,2),2,2],'LineWidth',2,'EdgeColor','b');end end pause(0.8);%每處理一張圖片暫停0.8秒 end

      軟件說明

      1、圖片組中圖片數(shù)量為7張,為RGB圖像,命名時從1~7編號。

      2、打開軟件后單擊“打開”按鈕,選中圖片組的第一張圖片,即可在左邊顯示該圖片。

      3、單擊“播放”按鈕,可以看到在左邊顯示圖片動畫。

      4、單擊“目標(biāo)跟蹤”按鈕,可以看到在右邊顯示出目標(biāo)的跟蹤效果。效果圖

      1、初始界面:

      單目標(biāo)跟蹤:

      2、打開第一張圖片:

      3、播放圖片組動畫:

      4、目標(biāo)追蹤,定位目標(biāo),顯示軌跡:

      多目標(biāo)跟蹤:

      5、打開第一張圖片:

      6、播放圖片組動畫:

      7、目標(biāo)追蹤,定位目標(biāo),顯示軌跡:

      第四篇:圖像處理實驗教學(xué)小結(jié)

      實驗一:通過學(xué)習(xí)Matlab的開發(fā)環(huán)境、基本語法和函數(shù),使學(xué)生基本熟悉了Matlab的使用方法、開發(fā)規(guī)則和基本技巧,同時,通過上機獨立練習(xí)Matlab圖像處理的實例,進(jìn)一步鞏固了所學(xué)內(nèi)容,為后續(xù)的Matlab圖像處理課程,提供了保證。

      實驗二:通過本次課程的學(xué)習(xí)和實踐,使學(xué)生對Matlab的圖像編碼知識有了全面深入的掌握,對Matlab的圖像處理方法有了深入的理解和認(rèn)識,并進(jìn)一步熟悉了Matlab的基本語法和程序設(shè)計流程,為獨立開發(fā)圖像處理程序奠定了良好的基礎(chǔ)。

      實驗三:本次課程是醫(yī)學(xué)圖像實習(xí)的最后一次實習(xí)課,通過本次課程的學(xué)習(xí)和實踐,使學(xué)生基本掌握了平滑濾波、中值濾波、sobel算子和laplacian算子應(yīng)用方法,同時,進(jìn)一步熟悉和掌握了在Matlab下,圖像模板運算的方法和技巧。

      大部分學(xué)生能夠在老師的指導(dǎo)下,獨立完成設(shè)計工作,并完整正確運行程序,得到正確結(jié)果,但有部分學(xué)生由于錄入速度較慢,沒有在課堂完成代碼錄入工作,安排其在課后完成剩余部分的錄入工作,并能夠正確運行。

      第五篇:MATLAB函數(shù)處理圖像實現(xiàn)膨脹腐蝕

      MATLAB函數(shù)處理圖像實現(xiàn)膨脹腐蝕

      一、實驗?zāi)康?/p>

      1、了解二值形態(tài)學(xué)的基本運算

      2、掌握二值圖像膨脹、腐蝕的基本方法

      3、編程實現(xiàn)膨脹、腐蝕

      二、實驗要求

      1、使用imdilate函數(shù)進(jìn)行圖像膨脹,并觀察膨脹后圖像的變化。

      2、使用imerode函數(shù)進(jìn)行圖像腐蝕,觀察腐蝕后的圖像變化情況。

      三、實驗原理

      膨脹:將與物體接觸的所有背景點合并到該物體中,使邊界向外部擴張的過程。利用它可以填補物體中的空洞。B對X膨脹所產(chǎn)生的二值圖像D是滿足以下條件的點(x,y)的集合:如果B的原點平移到點(x,y),那么它與X的交集非空。數(shù)學(xué)表達(dá)式:C?A?B

      腐蝕:一種消除邊界點,使邊界向內(nèi)部收縮的過程。利用它可以消除小而且無意義的物體。B對X腐蝕所產(chǎn)生的二值圖像E是滿足以下條件的點(x,y)的集合:如果B的原點平移到點(x,y),那么B將完全包含于X中。數(shù)學(xué)表達(dá)式:C?A?B

      膨脹處理:一種消除邊界點,使邊界點向內(nèi)部收縮的過程。

      腐蝕處理:將與物體接觸的所有背景點合并到該物體中,使邊界向外部擴張的過程。

      四、實驗步驟

      1.圖像膨脹的Matlab實現(xiàn):

      可以使用imdilate函數(shù)進(jìn)行圖像膨脹,imdilate函數(shù)需要兩個基本輸入?yún)?shù),即待處理的輸入圖像和結(jié)構(gòu)元素對象。結(jié)構(gòu)元素對象可以是strel函數(shù)返回的對象,也可以是一個自己定義的表示結(jié)構(gòu)元素鄰域的二進(jìn)制矩陣。此外,imdilate還可以接受兩個可選參數(shù):PADOPT(padopt)——影響輸出圖片的大小、PACKOPT(packopt).——說明輸入圖像是否為打包的二值圖像(二進(jìn)制圖像)。步驟1,首先創(chuàng)建一個包含矩形對象的二值圖像矩陣。>> BW=zeros(9,10);>> BW(4:6,4:7)=1 BW = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 步驟2,使用一個3×3的正方形結(jié)構(gòu)元素對象對創(chuàng)建的圖像進(jìn)行膨脹。>> SE=strel('square',3)SE = Flat STREL object containing 9 neighbors.Neighborhood: 1 1 1 1 1 1 1 1 1 步驟3,將圖像BW和結(jié)構(gòu)元素SE傳遞給imdilate函數(shù)。>> BW2=imdilate(BW,SE)BW2 = 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 0 0

      0 0 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 步驟4,顯示結(jié)果。>> imshow(BW,'notruesize')>> imshow(BW2,'notruesize')2.圖像腐蝕的Matlab實現(xiàn):

      可以使用imerode函數(shù)進(jìn)行圖像腐蝕。imerode函數(shù)需要兩個基本輸入?yún)?shù):待處理的輸入圖像以及結(jié)構(gòu)元素對象。此外,imerode函數(shù)還可以接受3個可選參數(shù):PADOPT(padopt)——影響輸出圖片的大小、PACKOPT(packopt).——說明輸入圖像是否為打包的二值圖像(二進(jìn)制圖像)。M——指定原始圖像的行數(shù)。以下程序示例說明了如何對某一副具體圖像進(jìn)行腐蝕操作,腐蝕前后的效果對比如圖末。

      步驟1,讀取圖像cameraman.tif(該圖像是Matlab當(dāng)前目錄下自帶的圖片)>> BW1=imread('cameraman.tif');步驟2,創(chuàng)建一個任意形狀的結(jié)構(gòu)元素對象 >> SE=strel('arbitrary',eye(5));步驟3,以圖像BW1和結(jié)構(gòu)元素SE為參數(shù)調(diào)用imerode函數(shù)進(jìn)行腐蝕操作。>> BW2=imerode(BW1,SE);步驟4,顯示操作結(jié)果 >> imshow(BW1)>> figure,imshow(BW2)

      五、實驗代碼及結(jié)果

      代碼:

      imerode函數(shù),該函數(shù)能夠?qū)崿F(xiàn)二值圖像的腐蝕操作; imdilate函數(shù),該函數(shù)能夠?qū)崿F(xiàn)二值圖像的膨脹操作; bw=imread(‘d:image1’)bw=rgb2gray(bw)se1=strel(‘disk’,11);

      se2=strel(‘line’,11,90);bw2= imdilate(bw,se2);bw1=imerode(bw,se1);imshow(bw),title(‘原圖’)figure,imshow(bw2), title(‘膨脹后的圖像’)figure,imshow(bw1), title(‘腐蝕后的圖像’)

      結(jié)果:

      膨脹后的圖像

      腐蝕后的圖像

      六、實驗心得體會

      通過本次的實驗,我了解了二值形態(tài)學(xué)的基本運算,掌握了二值圖像膨脹、腐蝕的基本方法,并且會運用編程實現(xiàn)膨脹、腐蝕,本次的實驗?zāi)康囊呀?jīng)完成,意識到在以后的生活中要了解做事情的目的,注重每一個與細(xì)節(jié),認(rèn)真思考遇到的所有問題,提高自己各方面的能力。感謝尹強老師教會我們理論與實踐知識,也讓我明白了什么是學(xué)習(xí),怎么樣學(xué)習(xí),為以后的生活奠定的基礎(chǔ)與指引了方向。

      下載matlab圖像處理小結(jié)word格式文檔
      下載matlab圖像處理小結(jié).doc
      將本文檔下載到自己電腦,方便修改和收藏,請勿使用迅雷等下載。
      點此處下載文檔

      文檔為doc格式


      聲明:本文內(nèi)容由互聯(lián)網(wǎng)用戶自發(fā)貢獻(xiàn)自行上傳,本網(wǎng)站不擁有所有權(quán),未作人工編輯處理,也不承擔(dān)相關(guān)法律責(zé)任。如果您發(fā)現(xiàn)有涉嫌版權(quán)的內(nèi)容,歡迎發(fā)送郵件至:645879355@qq.com 進(jìn)行舉報,并提供相關(guān)證據(jù),工作人員會在5個工作日內(nèi)聯(lián)系你,一經(jīng)查實,本站將立刻刪除涉嫌侵權(quán)內(nèi)容。

      相關(guān)范文推薦

        matlab圖像分割總結(jié)報告(定稿)

        課程總結(jié)報告 題目: 圖像分割程序設(shè)計 院 系 電氣與電子工程學(xué)院 專 業(yè) xxxx 班 級 研電16xx 學(xué) 號 116xxxxxx 姓 名 xx 2016年 11月3日 摘 要:圖像分割是圖像處理......

        matlabGUI圖像處理

        圖像處理 一、實習(xí)任務(wù) 利用MATLAB里面的一些特定函數(shù)和GUI可視化圖形界面設(shè)計一個屬于自己的photoshop,使其完成簡易的放大、縮小、截圖以及直方圖統(tǒng)計等功能。 二、實習(xí)......

        圖像處理 實驗報告

        摘要: 圖像處理,用計算機對圖像進(jìn)行分析,以達(dá)到所需結(jié)果的技術(shù)。又稱影像處理。基本內(nèi)容 圖像處理一般指數(shù)字圖像處理。數(shù)字圖像是指用數(shù)字?jǐn)z像機、掃描儀等設(shè)備經(jīng)過采樣和數(shù)字......

        圖像處理說課稿

        圖像處理 一、教材分析和教學(xué)地位分析 本節(jié)課是浙江教育出版社必修教材中第三章第三節(jié)第一課時的內(nèi)容,主要介紹了圖像處理的基本概念:分辨率、位圖和矢量圖、顏色、文件格式,以......

        圖像處理教學(xué)大綱

        《醫(yī)學(xué)數(shù)字圖像處理》課程教學(xué)大綱 課程編號: 課程名稱:醫(yī)學(xué)數(shù)字圖像處理 英文名稱:Medical Digital Image Processing 課程類型:專業(yè)課 總學(xué)時:54 (理論學(xué)時:27 實驗學(xué)時:27) 適用......

        《攝影與圖像處理初步》課程小結(jié)

        《攝影與圖像處理初步》課程小結(jié)《攝影與圖像處理初步》《攝影與圖像處理初步》是針對工科高等院校本科各專業(yè)開設(shè)的一門素質(zhì)培養(yǎng)與基本技能的提高課程,以啟迪智慧、培養(yǎng)富于......

        MatLab 知識小結(jié)

        MatLab 知識小結(jié) matlab常用到的永久變量。 ans:計算結(jié)果的默認(rèn)變量名。 i j:基本虛數(shù)單位。 eps:系統(tǒng)的浮點(F10a9Bg個oht): inf: 無限大,例1/0 nan NaN:非數(shù)值(N航a nmnb謝) pi......

        MATLAB實現(xiàn)數(shù)字信號處理范文合集

        數(shù)字信號處理說 明 書 目錄 一.摘要…………………………………3 二.課程設(shè)計目的………………………3 三.設(shè)計內(nèi)容……………………………3 四.設(shè)計原理……………………………......