image thumbnail

March 2013 Japanese webinar "Introduction to Image Processing and Computer Vision with MATLAB"

by

 

25 Mar 2013 (Updated )

Script used in the Japanese webinar for image processing and computer vision held on Mar. 01, 2013.

S1_2_Thresholding_morph_coin_rice.m
%% Copyright 2013 The MathWorks, Inc.
% This is a demo for thresholding, morphological image processing, blob analysis
%
% Original version can be found by the following command
%     web([docroot '/images/examples/correcting-nonuniform-illumination.html'])
% or in the following URL.
%     http://www.mathworks.com/help/releases/R2012b/images/examples/correcting-nonuniform-illumination_ja_JP.html


clear all; clc, close all, imtool close all;
% sԂɎs
%% 摜2l
I=imread('coins.png');  % t@C摜̓ǂݍ
figure; imshow(I);      % WindowŁA摜̕\

figure; imhist(I);      % qXgO\
I2=I>100;               % 召rZɂ摜̓l
figure; imshow(I2);
I3=imfill(I2, 'holes'); % ̓h‚Ԃ
figure; imshow(I3);

%% ʂ̉摜p2lƁAʒuʐς̕ς̎Zo
clear all; clc, close all, imtool close all;
I=imread('rice.png');
figure; imshow(I);           % 摜̕\

figure; imhist(I);           % qXgO\
figure; imshow(I>70);        % ΘbIɓK؂臒l̒T
figure; imshow(I>150);
figure; surf(double(I),'EdgeColor','none');% \ʃvbg

Ierode=imerode(I, ones(15)); % kɂė̏
figure; ...
surf(double(Ierode),'EdgeColor','none');% wi\ʃvbg

I2=I-Ierode;                            % wȉ
figure; surf(double(I2),'EdgeColor','none'); % \ʃvbg
figure; imhist(I2);
Ibw=I2>50;
figure; imshow(Ibw);
Ibw=bwareaopen(Ibw, 4);       % ׂȃmCY̏
figure; imshow(Ibw);
Iclr=imclearborder(Ibw);      % ؂Ă(OڐG)Ă̏
figure; imshow(Iclr);
stat=regionprops(Ibw, 'Area', 'Centroid')
stat(1)                    % 1Ԗڂ̕Ă̖ʐρA[xW, yW]
mean([stat.Area])             % ʐς̕

% I

Contact us