发 帖  
原厂入驻New
[讨论] 【液晶显示屏试用体验】补充贴—详细说明如何显示一幅图片
2017-4-21 00:20:42  2014 液晶显示屏
分享
上个月发布了结项报告,http://bbs.elecfans.com/jishu_1118656_1_1.html,详细说了SBN0064的工作逻辑。
但是坛友有人吐槽我“点亮就算结项了?!”
当时没有找到好用的取模软件,后来找到了一个,但是并不需要了,因为之前的贴子里已经有人详细说了字母+数字的字模了。今天说说如何取图片的字模。
一般图片如bmp、jpg其值都是3维矩阵。而本液晶屏只能显示01也就是二值图像。所以大概步骤是先用画图工具将分辨率调为256*32,然后matlab读取,再转为2值图像,此时得到一个32*256的矩阵。然后用MATLAB算出字模,添加到程序中。
例如,
I=imread('C:\Users\Jiao\Desktop\try.bmp');
bitm=im2bw(I);
imshow(bitm);
新建位图图像 (2).jpg
这是经过windows画图调分辨率,MATLAB转换后显示出的二值图像,右下角失真严重。
在MATLAB中得到的是一个bitm的32*256数组,通过下面的程序获取字模,每块芯片需要64*64/8=512个char型数据。程序如下:

byte1=zeros(8,64);%8*64数组,char型大小
byte2=zeros(8,64);%8*64数组,char型大小
tmp1=[];
tmp2=[];
%令tmp1和tmp2分别为保存64*64个点的矩阵
%1定义为芯片1的输出字,2定义为芯片2的输出字,各应为512个值;
for i=1:32
    for j=1:64        
        tmp1(i,j)=bitm(i,j);
        tmp1(i+32,j)=bitm(i,j+128);%因为两个芯片的控制域是交错的
        tmp2(i,j)=bitm(i,j+64);
        tmp2(i+32,j)=bitm(i,j+192);
    end
end
tmp=[];%每次取8个点来做字模,用tmp数组暂存
for i=1:8
    for j=1:64
        tmp(1:8)=tmp1(( (i*8-7):i*8),j);
        for k=1:8
            byte1(i,j)=byte1(i,j)+tmp(k)*2^(k-1);
        end
        tmp(1:8)=tmp2(( (i*8-7):i*8),j);
        for k=1:8
            byte2(i,j)=byte2(i,j)+tmp(k)*2^(k-1);
        end
    end
end
%把两个矩阵转为数组,可选
code1=[];
code2=[];
for i=1:8
    for j=1:64
        code1((i-1)*64+j)=byte1(i,j);
        code2((i-1)*64+j)=byte2(i,j);
    end
end

从MATLAB直接复制数据到代码文件中定义的uchar code code1[512]={}中,MATLAB自动给每两个数之间加了一个tab键,而C51要求数组元素之间用逗号分隔,这个可以采用编辑器如notepad++来进行替换:'\t'—>',',这样就得到所需要的字模了。
部分程序如下:
uchar code code1[512]={
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,223,223,199,231,231,231,199,199,199,199,207,111,111,111,127,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,223,143,159,159,159,159,159,143,207,207,207,207,231,103,103,55,51,51,19,155,139,139,201,65,5,33,1,17,145,241,248,120,120,124,124,124,252,252,254,254,254,254,255,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,127,63,63,31,31,15,15,135,199,131,195,225,241,240,248,124,60,30,30,14,135,195,227,241,240,248,252,254,126,127,126,62,60,28,24,24,0,224,224,224,193,193,129,1,5,13,
255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,252,254,254,254,255,255,255,255,255,255,255,255,255,225,192,192,192,192,192,192,224,225,225,225,240,240,240,240,248,248,248,252,252,252,254,254,255,255,255,255,255,255,255,255,255,254,
254,254,254,118,6,14,30,30,62,62,126,254,254,254,254,254,254,254,254,254,254,254,254,126,126,254,254,254,254,254,254,254,254,254,254,254,254,254,254,236,224,224,244,252,252,252,252,252,190,198,118,122,62,62,30,14,14,14,14,14,30,62,126,238,
0,0,0,0,0,0,0,96,32,48,48,48,48,48,48,48,48,48,48,48,48,48,112,96,96,96,224,224,224,225,241,243,251,255,255,255,255,255,255,255,255,255,255,255,255,127,127,35,1,0,0,0,0,0,0,0,0,0,0,0,192,240,239,255,
16,16,24,24,24,8,8,8,12,12,132,132,132,132,128,128,128,128,128,128,144,240,240,240,240,248,248,248,253,255,255,255,255,255,255,255,255,255,255,255,255,255,255,240,224,192,192,192,192,192,32,0,0,0,0,0,0,0,48,126,255,255,255,255,
254,254,254,254,254,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,254,254,63,127,63,191,63,63,63,63,63,63,126,120,56,56,48,32,32,32,240,242,255,255,251,249,
};
uchar code code2[512]={
255,255,255,252,252,252,252,240,248,248,248,248,248,252,252,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,252,252,252,252,252,252,252,252,252,252,254,254,254,254,254,254,254,
255,255,255,255,127,127,63,63,127,63,63,63,191,191,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,231,199,135,131,3,1,1,0,0,128,128,128,128,192,192,192,193,65,97,225,224,224,224,224,224,0,0,
13,12,24,24,28,30,62,62,126,127,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,239,15,3,1,0,0,0,0,0,128,224,32,16,16,
254,252,252,248,248,240,240,240,224,224,224,224,224,224,225,225,225,225,225,225,227,227,227,227,243,243,251,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,252,252,248,248,248,248,252,253,255,254,254,
22,30,18,2,10,6,6,0,0,128,134,134,2,3,3,3,3,3,1,1,1,1,1,1,33,33,33,49,49,125,127,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
222,220,244,196,194,64,65,97,145,4,3,0,0,0,0,128,128,0,1,1,132,132,128,0,0,0,0,0,0,0,64,64,119,127,127,127,127,191,127,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
255,255,127,127,63,59,59,7,7,27,6,34,32,32,0,64,0,0,1,8,8,8,0,4,0,0,0,0,0,0,0,32,32,48,0,8,0,66,65,63,63,63,191,191,191,191,191,63,63,191,127,127,127,127,127,127,127,127,127,127,255,255,255,255,
248,248,248,248,248,8,0,2,0,0,1,0,0,0,0,0,0,0,0,0,0,0,120,120,120,120,120,120,120,0,0,0,0,0,8,0,0,16,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,
};


main函数部分:
for(j=0; j<8; j++) {
                        page_address=j|0xB8;
                        CSA=1;
                        CSB=0;
                        write_command(page_address);  // left screen write
                        for (i=0; i<64; i++) {
                                write_data(code1[j*64+i]);
                        }
                }
                for(j=0; j<8; j++) {
                        page_address=j|0xB8;
                        CSA=0;
                        CSB=1;
                        write_command(page_address);  // left screen write
                        for (i=0; i<64; i++) {
                                write_data(code2[j*64+i]);
                        }
                }

这个程序编译并不提示文件大小超出。
另外,这个程序是由于我所用的字模软件不能提取彩色图片,其实用MATLAB转为二值图像就可以用字模软件来提取了。。。
附送字模软件及其截图:
新建位图图像 (3).jpg
字模提取V2.2.zip (256.79 KB, 下载次数: 2)




0
2017-4-21 00:20:42   评论 分享淘帖
2 个讨论
好贴
2017-4-23 22:47:06 评论

举报

非常好帖子
2017-5-1 10:17:54 评论

举报

只有小组成员才能发言,加入小组>>

83个成员聚集在这个小组

加入小组

热门话题

创建小组步骤

关闭

站长推荐 上一条 /7 下一条

快速回复 返回顶部 返回列表