www.gusucode.com > IPCV_Eval_Kit_R2019a_0ce6858工具箱matlab程序源码 > IPCV_Eval_Kit_R2019a_0ce6858/code/demo_files/I2_00f_coins_misc.m
clear;clc;close all;imtool close all %% 暔懱偺掕検昡壙乮柺愊啇S揰紝a鼒蛼穪j I = imread('coins.png'); % 夋憸偺撉崬 figure; imshow(I); % 昞帵 figure; imhist(I); % 僸僗僩僌儔儉昞帵 Ibw = I>100; % 敀崟偺夋憸傊曄姺 figure; imshow(Ibw); % 昞帵 Ibw = I>90; % 懳榖揑扵嶕 figure; imshow(Ibw); % 昞帵 Ibwf = imfill(Ibw, 'holes'); % 寠傪杽傔傞 figure; imshow(Ibwf); % 昞帵 Ibwc = bwareaopen(Ibwf, 10); % 偛傒偺彍嫀 (10僺僋僙儖埲壓偺傕偺) figure; imshow(Ibwc); % 昞帵 [懳榖揑側扵嶕] %% 奺椞堟偺柺愊丒拞怱揰丒捈宎丒廃埻挿傪媮傔傞 stats = regionprops('table', Ibwc, 'Area', 'Centroid', 'MajorAxisLength', 'Perimeter') % struct/table areas = stats.Area % 奺乆偺柺愊 mean(areas) % 柺愊偺暯嬒 figure;hist(areas); % 柺愊偺僸僗僩僌儔儉昞帵 figure;imshow(I);improfile % 慄暘偵増偭偨僺僋僙儖抣丗2揰傪儅僂僗塃僋儕僢僋偱巜掕偟儕僞乕儞 figure; surf(double(I));shading interp; % 3師尦昞帵(夞揮壜)丗僣乕儖儊僯儏乕撪偺"3師尦夞揮" %% %% 暔懱掕検昡壙偺寢壥傪夋憸忋偵彂崬傒 I1 = insertMarker(I, stats.Centroid, 'star', 'Color','red'); I2 = insertText(I1, stats.Centroid, cellstr(num2str(areas)), 'BoxOpacity',0, 'FontSize',10); I3 = insertText(I2, [160, 220], ['# of coins: ' num2str(size(stats, 1))], 'FontSize',16); figure; imshow(I3); hold on; visboundaries(Ibwc, 'Color','g'); hold off; %% 廔椆 %% 僄僢僕専弌 I = imread([matlabroot '\toolbox\coder\codegendemos\coderdemo_edge_detection\hello.jpg']); figure;imshow(I); G = rgb2gray(I); figure;imshow(G); Gcanny = edge(G,'canny',0.18); % 僄僢僕専弌丗僉儍僯乕朄 figure;imshow(Gcanny); %% 墌偺専弌 RGB = imread('tape.png'); % 僙儘僥乕僾偺夋憸 figure;imshow(RGB); [center, radius] = imfindcircles(RGB,[60 100],'Sensitivity',0.9) %墌偺専弌 viscircles(center,radius); % 墌偺昞帵 hold on; plot(center(:,1),center(:,2),'yx','LineWidth',4); hold off; %% 暯嬒壔僼傿儖僞乕張棟 Fave=fspecial('average'); % 僼傿儖僞乕學悢惗惉 Iave=imfilter(I, Fave); % 僼傿儖僞乕張棟 I=[I Iave]; % 塃墶偵暿偺夋憸傪奼挘 figure; imshow(I); % 昞帵 %% 慛柧壔張棟 Ish=imsharpen(Iave, 'Amount', 3); % 僼傿儖僞乕張棟丄嫮搙 figure; imshowpair(Iave, Ish, 'montage'); % 墶暲傃壜帇壔 fspecial('average') fspecial('average', 5) edit fspecial % fspecial娭悢偺幚憰昞帵 or 娭悢慖傫偱F4 doc % 廩幚偟偨僪僉儏儊儞僩 %% 廔椆 %% [嶲峫] % 鑷抣傪帺摦揑偵媮傔傞娭悢 Th = graythresh(I) % 戝捗朄傪巊偄偰夋憸偺擇抣壔梡鑷抣傪媮傔傞 Ibw = im2bw(I, Th); % 媮傔偨鑷抣傪梡偄偰夋憸偺擇抣壔 figure; imshow(Ibw); % 夋憸偺昞帵 doc % 僪僉儏儊儞僩傪奐偔 edit imfill % M尵岅偱彂偐傟偰偄傞娭悢傕懡偄偺偱幚憰傪屼妋擣偄偨偩偗傑偡 edit bwareaopen % Copyright 2014 The MathWorks, Inc.