image processing matlab
RGB和HSV有何不同
CMYK COLOR
===========================================
clc;
close all;
clear;
m=256;
n=256;
% R = zeros(m,n);
% G = zeros(m,n);
% B = zeros(m,n);
R = 255*ones(m,n);
G = 255*ones(m,n);
B = 255*ones(m,n);
figure, imshow(R), title('gary');
figure, imshow(G), title('gary');
figure, imshow(B), title('gary');
RGBI(:,:,1)=R;
RGBI(:,:,2)=G;
RGBI(:,:,3)=B;
figure, imshow(RGBI), title('RGBI');
================================================
clc;
close all;
clear;
m=256;
n=256;
% R = zeros(m,n);
% G = zeros(m,n);
% B = zeros(m,n);
R = 155*uint8(ones(m,n));
G = 55*uint8(ones(m,n));
B = 255*uint8(ones(m,n));
figure, imshow(R), title('gary');
figure, imshow(G), title('gary');
figure, imshow(B), title('gary');
RGBI(:,:,1)=R;
RGBI(:,:,2)=G;
RGBI(:,:,3)=B;
figure, imshow(RGBI), title('RGBI');
===============================================
===========================================
clc;
close all;
clear;
m=256;
n=256;
% R = zeros(m,n);
% G = zeros(m,n);
% B = zeros(m,n);
R = 155*uint8(ones(m,n));
G = 55*uint8(ones(m,n));
B = 255*uint8(ones(m,n));
figure, imshow(R), title('gary');
figure, imshow(G), title('gary');
figure, imshow(B), title('gary');
RGBI(:,:,1)=R;
RGBI(:,:,2)=G;
RGBI(:,:,3)=B;
figure, imshow(RGBI), title('RGBI');
===============================================
===========================================
================================================
clc;
close all;
clear;
%Step 1: Read Image
RGBI = imread('palmcontour.jpg');
figure, imshow(RGBI), title('original image');
R=RGBI(:,:,1);
G=RGBI(:,:,2);
B=RGBI(:,:,3);
figure, imshow(R), title('gary');
figure, imshow(G), title('gary');
figure, imshow(B), title('gary');
================================================
clc;
close all;
clear;
%Step 1: Read Image
RGBI = imread('palmcontour.jpg');
figure, imshow(RGBI), title('original image');
R=RGBI(:,:,1);
G=RGBI(:,:,2);
B=RGBI(:,:,3);
% figure, imshow(R), title('gary');
% figure, imshow(G), title('gary');
% figure, imshow(B), title('gary');
hsv_image = rgb2hsv(RGBI);
figure, imshow(hsv_image), title('HSV');
H=hsv_image(:,:,1);
S=hsv_image(:,:,2);
V=hsv_image(:,:,3);
figure, imshow(H), title('H gary');
figure, imshow(S), title('S gary');
figure, imshow(V), title('V gary');
================================================
===============================================
clc;
close all;
clear;
%Step 1: Read Image
RGBI = imread('palmcontour.jpg');
figure, imshow(RGBI), title('original image');
R=RGBI(:,:,1);
G=RGBI(:,:,2);
B=RGBI(:,:,3);
% figure, imshow(R), title('gary');
% figure, imshow(G), title('gary');
% figure, imshow(B), title('gary');
hsv_image = rgb2hsv(RGBI);
figure, imshow(hsv_image), title('HSV');
H=hsv_image(:,:,1);
S=hsv_image(:,:,2);
V=hsv_image(:,:,3);
% figure, imshow(H), title('H gary');
% figure, imshow(S), title('S gary');
% figure, imshow(V), title('V gary');
rgb = RGBI;
cform = makecform('srgb2lab');
lab = applycform(rgb,cform);
figure, imshow(lab), title('lab');
L=lab(:,:,1);
A=lab(:,:,2);
B=lab(:,:,3);
figure, imshow(L), title('l gary');
figure, imshow(A), title('a gary');
figure, imshow(B), title('b gary');
================================================
================================================
clc;
close all;
clear;
%Step 1: Read Image
RGBI = imread('palmcontour.jpg');
figure, imshow(RGBI), title('original image');
R=RGBI(:,:,1);
G=RGBI(:,:,2);
B=RGBI(:,:,3);
% figure, imshow(R), title('gary');
% figure, imshow(G), title('gary');
% figure, imshow(B), title('gary');
hsv_image = rgb2hsv(RGBI);
figure, imshow(hsv_image), title('HSV');
H=uint8(hsv_image(:,:,1)*255);
S=uint8(hsv_image(:,:,2)*255);
V=uint8(hsv_image(:,:,3)*255);
BH=H<90;
figure, imshow(BH), title('BINARY H');
% figure, imshow(H), title('H gary');
% figure, imshow(S), title('S gary');
% figure, imshow(V), title('V gary');
rgb = RGBI;
cform = makecform('srgb2lab');
lab = applycform(rgb,cform);
figure, imshow(lab), title('lab');
L=lab(:,:,1);
A=lab(:,:,2);
B=lab(:,:,3);
figure, imshow(L), title('l gary');
figure, imshow(A), title('a gary');
figure, imshow(B), title('b gary');
===========================================================
================================================
clc;
close all;
clear;
%Step 1: Read Image
RGBI = imread('palmcontour1.jpg');
figure, imshow(RGBI), title('original image');
R=RGBI(:,:,1);
G=RGBI(:,:,2);
B=RGBI(:,:,3);
% figure, imshow(R), title('gary');
% figure, imshow(G), title('gary');
% figure, imshow(B), title('gary');
hsv_image = rgb2hsv(RGBI);
figure, imshow(hsv_image), title('HSV');
H=uint8(hsv_image(:,:,1)*255);
S=uint8(hsv_image(:,:,2)*255);
V=uint8(hsv_image(:,:,3)*255);
BHh=H>230;
figure, imshow(BHh), title('BINARY Hh');
BHl=H<30;
figure, imshow(BHl), title('BINARY Hl');
BHt=or(BHh, BHl);
figure, imshow(BHt), title('BINARY Ht');
figure, imshow(H), title('H gary');
figure, imshow(S), title('S gary');
figure, imshow(V), title('V gary');
rgb = RGBI;
cform = makecform('srgb2lab');
lab = applycform(rgb,cform);
%figure, imshow(lab), title('lab');
L=lab(:,:,1);
A=lab(:,:,2);
B=lab(:,:,3);
% figure, imshow(L), title('l gary');
% figure, imshow(A), title('a gary');
% figure, imshow(B), title('b gary');
================================================
================================================
close all;
originalRGB = imread('peppers.png');
imshow(originalRGB);
h = fspecial('motion', 50, 45);
filteredRGB = imfilter(originalRGB, h);
figure, imshow(filteredRGB);
====================================================
================================================
1. 滑鼠選取影像中的區塊
--------------------------------------------------------------------------------------------------------------------------------------------
close all;
clear;
clc;
load mandrill
% [X,map] = imread('eight.tif');
figure('color','k')
image(X)
colormap(map)
axis off % Remove axis ticks and numbers
axis image % Set aspect ratio to obtain square pixels
k = waitforbuttonpress;
point1 = get(gca,'CurrentPoint'); % button down detected
finalRect = rbbox; % return figure units
point2 = get(gca,'CurrentPoint'); % button up detected
point1 = point1(1,1:2); % extract x and y
point2 = point2(1,1:2);
p1 = min(point1,point2); % calculate locations
offset = abs(point1-point2); % and dimensions
x = [p1(1) p1(1)+offset(1) p1(1)+offset(1) p1(1) p1(1)];
y = [p1(2) p1(2) p1(2)+offset(2) p1(2)+offset(2) p1(2)];
hold on
axis manual
plot(x,y)
I=X(p1(1):p1(1)+offset(1),p1(2):p1(2)+offset(2),:);
figure('color','k')
image(I)
colormap(map)
axis off % Remove axis ticks and numbers
axis image % Set aspect ratio to obtain square pixels
-------------------------------------------------------------------------------------------------------------------------------------------------
沒有留言:
張貼留言