Digital image processing of large operations, the picture of the part of the CAP positioning
Fortunately little cute help me, and classmates, the code is written by themselves (including Baidu in the code) thinking is not what they want to continue to work hard.
matlab
Clear;
CLC;
Close all;
A = Imread (' C:\Users\Public\Pictures\Sample pictures\topic1. JPG ');
HV=RGB2HSV (a);
% can see a picture of the HSV three channel
H=HV (:,:, 1) through the following procedure;
S=HV (:,:, 2);
V=HV (:,:, 3);
Subplot (2,1,1); Imshow (a); title (' Original image ');
%subplot (1,2,2); imshow (HV); title (' HSV Space I image ');
%subplot (1,3,1); Imshow (h); title (' HSV Space H-component image ');
%subplot (1,3,2); Imshow (s); title (' HSV Space S-component image ');
%subplot (1,3,3); Imshow (v); title (' HSV Space V-component image ');
I=mat2gray (S);
IBW=IM2BW (I);
[L,m]=bwlabel (ibw,8);
Status=regionprops (L, ' area ', ' BoundingBox ');
areas = [status. Area];
Rects = Cat (1, status. BoundingBox);
[~, max_id] = max (areas);
Max_rect = Rects (max_id,:);
% show the largest connected region
subplot (2,1,2); Imshow (a); Title (' Results ');
Rectangle (' position ', max_rect, ' Edgecolor ', ' R ');