Demo entry 6357958

1

   

Submitted by 1 on Apr 24, 2017 at 10:14
Language: Matlab. Code size: 4.8 kB.

im=imread('0.JPG');
%提取X轴特征块RGB范围
[X,rect_x]=imcrop(im);
%X轴R值范围
xr_a=X(:,:,1);
xr_b=imhist(xr_a);
[xr_c,xr_d]=max(xr_b);
xr_e=0.2*xr_c;
xr_f=xr_b(1:xr_d,:);
[xr_m,xr_n]=min(abs(xr_f-xr_d))
xr_g=xr_b(xr_d:256,:);
[xr_m1,xr_n0]=min(abs(xr_g-xr_d))
xr_n1=xr_d+xr_n0;
%X轴G值范围
xg_a=X(:,:,2);
xg_b=imhist(xg_a);
[xg_c,xg_d]=max(xg_b);
xg_e=0.2*xg_c;
xg_f=xg_b(1:xg_d,:);
[xg_m,xg_n]=min(abs(xg_f-xg_d))
xg_g=xg_b(xg_d:256,:);
[xg_m1,xg_n0]=min(abs(xg_g-xg_d))
xg_n1=xg_d+xg_n0;
%X轴B值范围
xb_a=X(:,:,3);
xb_b=imhist(xb_a);
[xb_c,xb_d]=max(xb_b);
xb_e=0.2*xb_c;
xb_f=xb_b(1:xb_d,:);
[xb_m,xb_n]=min(abs(xb_f-xb_d))
xb_g=xb_b(xb_d:256,:);
[xb_m1,xb_n0]=min(abs(xb_g-xb_d))
xb_n1=xb_d+xb_n0;
%提取Y轴特征块RGB范围
[Y,rect_x]=imcrop(im);
%Y轴R值范围
yr_a=Y(:,:,1);
yr_b=imhist(yr_a);
[yr_c,yr_d]=max(yr_b);
yr_e=0.2*yr_c;
yr_f=yr_b(1:yr_d,:);
[yr_m,yr_n]=min(abs(yr_f-yr_d))
yr_g=yr_b(yr_d:256,:);
[yr_m1,yr_n0]=min(abs(yr_g-yr_d))
yr_n1=yr_d+yr_n0;
%Y轴G值范围
yg_a=Y(:,:,2);
yg_b=imhist(yg_a);
[yg_c,yg_d]=max(yg_b);
yg_e=0.2*yg_c;
yg_f=yg_b(1:yg_d,:);
[yg_m,yg_n]=min(abs(yg_f-yg_d))
yg_g=yg_b(yg_d:256,:);
[yg_m1,yg_n0]=min(abs(yg_g-yg_d))
yg_n1=yg_d+yg_n0;
%Y轴B值范围
yb_a=Y(:,:,3);
yb_b=imhist(yb_a);
[yb_c,yb_d]=max(yb_b);
yb_e=0.2*yb_c;
yb_f=yb_b(1:yb_d,:);
[yb_m,yb_n]=min(abs(yb_f-yb_d))
yb_g=yb_b(yb_d:256,:);
[yb_m1,yb_n0]=min(abs(yb_g-yb_d))
yb_n1=yb_d+yb_n0;
%提取原点特征块RGB范围
[O,rect_o]=imcrop(im);
%O轴R值范围
or_a=O(:,:,1);
or_b=imhist(or_a);
[or_c,or_d]=max(or_b);
or_e=0.2*or_c;
or_f=or_b(1:or_d,:);
[or_m,or_n]=min(abs(or_f-or_d))
or_g=or_b(or_d:256,:);
[or_m1,or_n0]=min(abs(or_g-or_d))
or_n1=or_d+or_n0;
%O轴G值范围
og_a=O(:,:,2);
og_b=imhist(og_a);
[og_c,og_d]=max(og_b);
og_e=0.2*og_c;
og_f=og_b(1:og_d,:);
[og_m,og_n]=min(abs(og_f-og_d))
og_g=og_b(og_d:256,:);
[og_m1,og_n0]=min(abs(og_g-og_d))
og_n1=og_d+og_n0;
%O轴B值范围
ob_a=O(:,:,3);
ob_b=imhist(ob_a);
[ob_c,ob_d]=max(ob_b);
ob_e=0.2*ob_c;
ob_f=ob_b(1:ob_d,:);
[ob_m,ob_n]=min(abs(ob_f-ob_d))
ob_g=ob_b(ob_d:256,:);
[ob_m1,ob_n0]=min(abs(ob_g-ob_d))
ob_n1=ob_d+ob_n0;
%提取备用特征块RGB范围
[S,rect_s]=imcrop(im);
%S轴R值范围
sr_a=S(:,:,1);
sr_b=imhist(sr_a);
[sr_c,sr_d]=max(sr_b);
sr_e=0.2*sr_c;
sr_f=sr_b(1:sr_d,:);
[sr_m,sr_n]=min(abs(sr_f-sr_d))
sr_g=sr_b(sr_d:256,:);
[sr_m1,sr_n0]=min(abs(sr_g-sr_d))
sr_n1=sr_d+sr_n0;
%S轴G值范围
sg_a=S(:,:,2);
sg_b=imhist(sg_a);
[sg_c,sg_d]=max(sg_b);
sg_e=0.2*sg_c;
sg_f=sg_b(1:sg_d,:);
[sg_m,sg_n]=min(abs(sg_f-sg_d))
sg_g=sg_b(sg_d:256,:);
[sg_m1,sg_n0]=min(abs(sg_g-sg_d))
sg_n1=sg_d+sg_n0;
%S轴B值范围
sb_a=S(:,:,3);
sb_b=imhist(sb_a);
[sb_c,sb_d]=max(sb_b);
sb_e=0.2*sb_c;
sb_f=sb_b(1:sb_d,:);
[sb_m,sb_n]=min(abs(sb_f-sb_d))
sb_g=sb_b(sb_d:256,:);
[sb_m1,sb_n0]=min(abs(sb_g-sb_d))
sb_n1=sb_d+sb_n0;
%绘图
subplot(4,3,1),imhist(X(:,:,1)),hold on,line([xr_n,xr_n],[0,xr_c],'color','red'),hold on,line([xr_n1,xr_n1],[0,xr_c],'color','red'),title('第一次截图R值分布');
subplot(4,3,2),imhist(X(:,:,2)),hold on,line([xg_n,xg_n],[0,xg_c],'color','red'),hold on,line([xg_n1,xg_n1],[0,xg_c],'color','red'),title('第一次截图G值分布');
subplot(4,3,3),imhist(X(:,:,3)),hold on,line([xb_n,xb_n],[0,xb_c],'color','red'),hold on,line([xb_n1,xb_n1],[0,xb_c],'color','red'),title('第一次截图B值分布');
subplot(4,3,4),imhist(Y(:,:,1)),hold on,line([yr_n,yr_n],[0,yr_c],'color','red'),hold on,line([yr_n1,yr_n1],[0,yr_c],'color','red'),title('第二次截图R值分布');
subplot(4,3,5),imhist(Y(:,:,2)),hold on,line([yg_n,yg_n],[0,yg_c],'color','red'),hold on,line([yg_n1,yg_n1],[0,yg_c],'color','red'),title('第二次截图G值分布');
subplot(4,3,6),imhist(Y(:,:,3)),hold on,line([yb_n,yb_n],[0,yb_c],'color','red'),hold on,line([yb_n1,yb_n1],[0,yb_c],'color','red'),title('第二次截图B值分布');
subplot(4,3,7),imhist(O(:,:,1)),hold on,line([or_n,or_n],[0,or_c],'color','red'),hold on,line([or_n1,or_n1],[0,or_c],'color','red'),title('第三次截图R值分布');
subplot(4,3,8),imhist(O(:,:,2)),hold on,line([og_n,og_n],[0,og_c],'color','red'),hold on,line([og_n1,og_n1],[0,og_c],'color','red'),title('第三次截图G值分布');
subplot(4,3,9),imhist(O(:,:,3)),hold on,line([ob_n,ob_n],[0,ob_c],'color','red'),hold on,line([ob_n1,ob_n1],[0,ob_c],'color','red'),title('第三次截图B值分布');
subplot(4,3,10),imhist(S(:,:,1)),hold on,line([sr_n,sr_n],[0,sr_c],'color','red'),hold on,line([sr_n1,sr_n1],[0,sr_c],'color','red'),title('第四次截图R值分布');
subplot(4,3,11),imhist(S(:,:,2)),hold on,line([sg_n,sg_n],[0,sg_c],'color','red'),hold on,line([sg_n1,sg_n1],[0,sg_c],'color','red'),title('第四次截图G值分布');
subplot(4,3,12),imhist(S(:,:,3)),hold on,line([sb_n,sb_n],[0,sb_c],'color','red'),hold on,line([sb_n1,sb_n1],[0,sb_c],'color','red'),title('第四次截图B值分布');
RGB=[xr_n,xr_n1;xg_n,xg_n1;xb_n,xb_n1;yr_n,yr_n1;yg_n,yg_n1;yb_n,yb_n1;or_n,or_n1;og_n,og_n1;ob_n,ob_n1;sr_n,sr_n1;sg_n,sg_n1;sb_n,sb_n1];
save RGB.txt RGB -ascii

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).