⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 color_test.m

📁 用于进行车牌校正的程序
💻 M
字号:
clear all;
clc;
im_CP = imread('dt666.jpg');

%%蓝色部分
im_color1 = im_CP;
[height,width,w] = size(im_CP);
for i = 1:height
    for j = 1:width
        if ((im_CP(i,j,1)>=15 & im_CP(i,j,1)<=50) &...
                (im_CP(i,j,2)>=25 & im_CP(i,j,2)<=50) &...
                (im_CP(i,j,3)>=65 & im_CP(i,j,3)<=140))
            
                im_color1(i,j,:) = 0;
        else   im_color1(i,j,:) = 255;
        end
    end
end

figure;
imshow(im_color1);

%%白色字体部分
im_color2 = im_CP;
for i = 1:height
    for j = 1:width
        if ((im_CP(i,j,1)>=55 & im_CP(i,j,1)<=170) &...
                (im_CP(i,j,2)>=65 & im_CP(i,j,2)<=180) &...
                (im_CP(i,j,3)>=130 & im_CP(i,j,3)<=220))
            
                im_color2(i,j,:) = 0;
        else   im_color2(i,j,:) = 255;
        end
    end
end

figure;
imshow(im_color2);
        
%%灰白色边框部分
im_color3 = im_CP;
for i = 1:height
    for j = 1:width
        if ((im_CP(i,j,1)>=120 & im_CP(i,j,1)<=140) &...
                (im_CP(i,j,2)>=115 & im_CP(i,j,2)<=135) &...
                (im_CP(i,j,3)>=115 & im_CP(i,j,3)<=150)) 
            
                im_color3(i,j,:) = 0;
        else   im_color3(i,j,:) = 255;
        end
    end
end

figure;
imshow(im_color3);

%%字体与蓝色部分的颜色对
im_color4 = im_CP;
for i = 1:height
    for j = 1:width
        if (j~=width) &...%%当前点为蓝色%%下一个点为白色 或者 当前点为白色下一个点为蓝色
                ((((im_CP(i,j,1)>=15 & im_CP(i,j,1)<=50) &...
                (im_CP(i,j,2)>=25 & im_CP(i,j,2)<=50) &...
                (im_CP(i,j,3)>=65 & im_CP(i,j,3)<=140))&...
                ((im_CP(i,j+1,1)>=55 & im_CP(i,j+1,1)<=170) &...
                (im_CP(i,j+1,2)>=65 & im_CP(i,j+1,2)<=180) &...
                (im_CP(i,j+1,3)>=130 & im_CP(i,j+1,3)<=220)))   |...     
                (((im_CP(i,j,1)>=55 & im_CP(i,j,1)<=170) &...
                (im_CP(i,j,2)>=65 & im_CP(i,j,2)<=180) &...
                (im_CP(i,j,3)>=130 & im_CP(i,j,3)<=220))&...
                ((im_CP(i,j+1,1)>=15 & im_CP(i,j+1,1)<=50) &...
                (im_CP(i,j+1,2)>=25 & im_CP(i,j+1,2)<=50) &...
                (im_CP(i,j+1,3)>=65 & im_CP(i,j+1,3)<=140))))
                            
                im_color4(i,j,:) = 0;
                im_color4(i,j+1,:) = 0;
        else   im_color4(i,j,:) = 255;
        end
    end
end

figure;
imshow(im_color4);




      
%%边框与蓝色部分的颜色对
im_color5 = im_CP;
for i = 1:height
    for j = 1:width
        if (j~=width) & ...  %%当前点为灰色%%下一个点为蓝色 
                (((im_CP(i,j,1)>=120 & im_CP(i,j,1)<=140) &...
              (im_CP(i,j,3)>=115 & im_CP(i,j,3)<=150))&...
                  (im_CP(i,j,2)>=115 & im_CP(i,j,2)<=135) &...
                ((im_CP(i,j+1,1)>=55 & im_CP(i,j+1,1)<=170) &...
                (im_CP(i,j+1,2)>=65 & im_CP(i,j+1,2)<=180) &...
                  (im_CP(i,j+1,3)>=130 & im_CP(i,j+1,3)<=220)))  
%              |...    
%                 (((im_CP(i,j,1)>=55 & im_CP(i,j,1)<=170) &...
%                 (im_CP(i,j,2)>=65 & im_CP(i,j,2)<=180) &...
%                 (im_CP(i,j,3)>=130 & im_CP(i,j,3)<=220))&...
%                 ((im_CP(i,j+1,1)>=120 & im_CP(i,j+1,1)<=140) &...
%                 (im_CP(i,j+1,2)>=115 & im_CP(i,j+1,2)<=135) &...
%                 (im_CP(i,j+1,3)>=115 & im_CP(i,j+1,3)<=150))))
                            
                im_color5(i,j,:) = 0;
                im_color5(i,j+1,:) = 0;
        else   im_color5(i,j,:) = 255;
        end
    end
end

figure;
imshow(im_color5);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -