BMP stm32图像识别 32*32的 有空心的丶...

您的位置:
> 图像转换下载
图像转换下载
图像转换就是使用图像转换软件将图片进行格式、尺寸等的转换,可在bmp、jpg、gif、tif、pcx等格式中自由转换。
软件下载导航
热门软件下载
手机设计本
随时提问题,随意赏美图
设计本官方微信
扫描二维码,即刻与本本亲密互 动,还有更多美图等你来看!
免责声明:本网站部分内容由用户自行上传,如权利人发现存在误传其作品情形,请及时与本站联系。
(,All Rights Reserved.()将24位 .bmp 格式图片转换为字符图画_24位bmp转换为32位_词汇网
将24位 .bmp 格式图片转换为字符图画
责任编辑:词汇网 发表时间: 4:44:58
本汇编程序是将24Bit位图图像转换成文本图画
运行环境为: 32位 windows + masm 6.0
windows 7的 cmd.exe如果不能运行本程序,可以用 DOSBOX来运行本程序;
运行本程序时,需要将要转换的 24bit .bmp格式位图图片放置在 masm 6.0 的文件夹里;
图片名字不能含有中文和空格;
输出字符图画文件在本目录下;
例如,将名为 24-lena.bmp的24bit .bmp格式图片转换为字符图画: 1、运行命令行; 2、 T5.EXE; 3、bmp2txt 24-lena.bmp d.txt
这个程序虽然写地很粗糙,重要的地方都标了注释,有一定汇编基础的应该没什么太多问题吧……就这么多,欢迎拍砖 ^_^
代码片段(5)[全屏查看所有代码] 1.[文件] bmp2txt.zip~1MB 下载(45) 2.[图片] 图片1.png
3.[图片] 图片2.jpg
4.[图片] 图片3.png
5.[代码]汇编, MASM 6.0 NAMETRYING......; append dat the transfer part (but : 1. the picture is reversed b 2. the picture is not well matched by its gray value and the ASCII code..); the corresponding ASCII code for different gray upside the . command line included !; which means operating !; addin .......386STACKSEGMENTUSE16 STACKDB200DUP(0)STACKENDSDATASEGMENTUSE16CMDLINEDB80DB?DB80 DUP(0)NAMEFDB30 DUP(0) ; THE NAME OF FILE TO BE CREATEDHANDLE1DW ? ; THE CODE OF TXT FILEFNAMEDB30 DUP(0) ; the image to be transferdHANDLE2DW? ; THE CODE OF IMAGE FILEASCIICODEDB "@", "#", "&", "K", "?", "+", ";", ".", " ", 00HGRAYCLASSDIVDB36 ; 0 - 255 gray value is divided into 8 classes, 36 pieces per classROWDD 0ROWCOUNTDD 0COLDD 0COLCOUNTDD 0PIXELCOUNTDD 0BF_SIZEDD1 ; bfSize, double word, the length of fileBIWIDTHDD0 ; biWidth, double word, the width of imageBIHEIGHTDD 0 ; biHeight, double word, the height of imageBISIZEIMGDD0 ; biSizeImage, double word, the data length of image partBIXPERDD0 ; biXPerlsPerMeter, double word, the X resolutionBIYPERDD0 ; biYPerlsPerMeter, double word, the Y resolutionBDB0 ; the pixel of blue componentGDB0 ; the pixel of green componentRDB0 ; the pixel of red componentGRAYDB0 ; the pixel transformation resultTMPDW0LASTGRAYDW0 ; the last place of insert in BUF3; the footprint of cursor in image file on its waying picking data from image file into area BUF2WORD3ADW 0 ; the low 16bit of answerWORD3BDW 0 ; the low 16bit of answerWORD1ADW ? ; the low 16bitWORD1BDW ? ; the heigh 16bitWORD2ADW ? ; the low 16bitWORD2BDW ? ; the heigh 16bitONEPICKODW0 ; THE BYTES TO BE PICKED IN A ROW LOOP, positive numberONEPICKNDW0 ; the negative numberLINEALLIGDW4 ; the number of data bytes should be divided by 4 without remainACTWRITTENDW0 ; the actual length of one bunch data to be wrote equals BIWIDTH and 2 (refers to 0dh, 0ah in order to start another line for data); to get image file"s head informationBUFDB54 DUP(0); to save data for temprorilyBUF2DB24000 DUP(0); noted that 0dh, 0ah occupy 2 bits o example: if the string to be wrote contains 10 then in order to write this string, the rigester CX shoud be 10+2 = 12BUF3DB0dh, 0ah, 24002 DUP(0) ; BUF ZONE TO BE WROTE INTO THE FILE, 5kbERMSG1DB"CREATE FILE ERROR! $"ERMSG2DB"OPEN FILE ERROR! $"ERMSG3DB"WRITE FILE ERROR! $"ERMSG4DB"THE SPACE IS NOT ENOUGH! $"ERMSG5DB"POINT FAILED! $"ERMSG6DB"CLOSE FILE ERROR! $"ERMSG7DB"READ FILE ERROR! $"ERMSG8DB"COMMAND INPUT ERROR! $"ERMSG9DB"IMAGE MUST BE *.bmp $"ERMSG10DB"OUTPUT FILE MUST BE *.txt $"CRLFDB0DH, 0AH, "$"MSG0DB "------------------------------------------------------------", 0DH, 0AH, "$"MSG1DB"WELCOME TO MY FIRST ASSEMLELY SOFT ", 0DH, 0AH, 0DH, 0AH, "$"MSG2DB"TO COVERT YOUR *.BMP FILE INTO *.TXT FILE: ", 0DH, 0AH, "$"MSG3DB" 1. PUT *.BMP FILE INTO THE DOCUMENT WHERE THIS PROGRAM LIES ", 0DH, 0AH, "$"MSG4DB" 2. USE DOS RUNNING THIS PROGRAM ", 0DH, 0AH, "$"MSG5DB" 3. COMMAND: bmp2txt *.bmp *.txt ", 0DH, 0AH, "$"MSG6DB0DH, 0AH, "NOTICE: no anyother extra character is allowed! ", 0DH, 0AH, "$"MSG7DB"COMMAND: $"MSG8DB0DH, 0AH, "XXXXXX XXXXXX PPPPPPPPPPPPPPPPPPPP", 0DH, 0AH, "$" MSG9DB" XXXXXX XXXXXX PPPPPPPPPPPPPPPPPPPP", 0DH, 0AH, "$" MSG10DB" XXXXXX XXXXXX PPPPPP PPPPPP", 0DH, 0AH, "$" MSG11DB" XXXXXX XXXXXX PPPPPP PPPPPP", 0DH, 0AH, "$" MSG12DB" XXXXXXXXXXXX PPPPPPPPPPPPPPPPPPPP", 0DH, 0AH, "$" MSG13DB" XXXXXX XXXXXX PPPPPP", 0DH, 0AH, "$"MSG14DB" XXXXXX XXXXXX PPPPPP", 0DH, 0AH, "$" MSG15DB" XXXXXX XXXXXX PPPPPP", 0DH, 0AH, "$"MSG16DB"XXXXXX XXXXXX PPPPPP CS1004", 0DH, 0AH, 0DH, 0AH, "$"MSG17DB" CONGRADULATIONS !", 0DH, 0AH, "$"DATAENDSCODESEGMENTUSE16ASSUMECS: CODE, DS: DATA, SS: STACK;....................................................MAINPROCFARMOVAX, DATAMOVDS, AXCALLNOTICECALLCMD; create the target .txt fileXORAX, AXMOVAH, 3CH ; create txt fileLEADX, NAMEFMOVCX, 00INT21HJCSHOWERMSG1MOVHANDLE1, AXXORAX, AXMOVAH, 3EH ; CLOSE TXT FILEMOVBX, HANDLE1INT 21HJCSHOWERMSG6CALLSHOWPROCESS1XORAX, AXLEADX, FNAME ; OPEN THE IMAGEMOVAH, 3DHMOVAL, 02HINT 21HJCSHOWERMSG2MOVHANDLE2, AXMOVBX, HANDLE2 ; READ 54 BYTES" DATA FROM IMAGEMOVAH, 3FHMOVCX, 54 ; the 54bits from the beginning contains basic discribtion of the imageMOVDX, OFFSET BUFINT21HMOVAH, 3EH ; CLOSE IMAGE FILEINT 21H; PICK USEFUL DATA INTO ITS VARIABLEMOVEAX, DWORD PTR BUF[2H]MOVBF_SIZE, EAX ; move data bfSize from file to variable BF_SIZEMOVEAX, DWORD PTR BUF[12H]MOVBIWIDTH, EAX ; move data biWidth from file to variable BIWIDTHMOVEAX, DWORD PTR BUF[16H]MOVBIHEIGHT, EAX; move data biHeight from file to variable BIHEIGHTMOVEAX, DWORD PTR BUF[22H]MOVBISIZEIMG, EAX; move data biSizeImage from file to variable BISIZEIMGMOVEAX, DWORD PTR BUF[26H]MOVBIXPER, EAX; move data biXPerlsPerMeter from file to variable BIXPERMOVEAX, DWORD PTR BUF[2AH]MOVBIYPER, EAX ; move data biYPerlsPerMeter from file to variable BIYPER; calculate the real number of bits to be written into target file for each timeMOVCX, WORD PTR BIWIDTHADDCX, 2 ; the actual length of one bunch data to be wrote equals BIWIDTH and 2 (refers to 0dh, 0ah in order to start another line for data)MOVACTWRITTEN, CX; calculate the number of bytes pick for one rowMOVAX, 3MULBIWIDTH ; EAX * OPS => EDX(HIGHT PART), EAX(LOW PART)MOVONEPICKO, AX; the number of data bytes should be divided by 4 without remainMODIFY:XOREDX, EDXDIVLINEALLIGCMPEDX, 0JENEXTINCONEPICKOMOVAX, ONEPICKOJMPMODIFY;....................................................; transfer partNEXT:; initial thvalue of row, rowcount, WORD1A, WORD1B, WORD2A, WORD2B; calculate the opsite number of ONEPICK got aboveCALLSHOWPROCESS2MOVAX, ONEPICKONOTAXADDAX, 1MOVONEPICKN, AX ; in order to move the file pointer from the end of .txt file to the beginningMOVEAX, BIHEIGHTMOVROW, EAXXOREAX, EAXMOVROWCOUNT, EAXXORAX, AXMOVWORD1A, AXMOVWORD1B, AXMOVWORD2B, AXMOVAX, ONEPICKOMOVWORD2A, AXROWLOOP:; start row loop with if row != rowcount, then continue this loop, else, get out of this loopMOVEAX, ROWCOUNTCMPEAX, ROWJETOEND; deal with cursor" WORD3B(high 16bits),WORD3A(low 16bits) contains it and, WORD3B = WORD2B + WORD1B, WORD3A = WORD2A + WORD1A;CALLADDBIG; open the image fileXORAX, AXMOVAH, 3DHMOVAL, 00H ; read onlyLEADX, FNAMEINT21HJCSHOWERMSG2MOVHANDLE2, AX; move image file"s pointer to the place where last loop stopXORAX, AXMOVAH, 42HMOVAL, 02 00 moves from the very beginning to the end of the file, 2 moves from the end of the file to the beginningMOVBX, HANDLE2MOVCX, WORD3BMOVDX, WORD3AINT21HJCSHOWERMSG5; pick onepick number"s data into BUF2 areaXORAX, AXMOVAH, 3FHMOVBX, HANDLE2MOVCX, ONEPICKOLEADX, BUF2INT21HJCSHOWERMSG7; close image fileXORAX, AXMOVAH, 3EHMOVBX, HANDLE2INT21HJCSHOWERMSG6; save cursor"s current positionMOVAX, WORD3AMOVWORD2A, AXMOVAX, WORD3BMOVWORD2B, AXMOVAX, ONEPICKNMOVWORD1A, AXCWDMOVWORD1B, DX; initial thvalue of col, colcount, pointer in area BUF2 picking data(which is colcount), pointer in BUF3 saving data(SI)MOVEAX, BIWIDTHMOVCOL, EAXXOREAX, EAXMOVCOLCOUNT, EAXMOVPIXELCOUNT, EAXMOVLASTGRAY, 2COLLOOP:; start col loop with if col != colcount, then continue this loop, else, get out of this loopMOVEAX, COLCMPEAX, COLCOUNTJETOROWLOOP; pick 3bits data from BUF2 area to calculate its gray value for each timeMOVEDI, PIXELCOUNTMOVAL, BUF2[EDI] ; pick blue pixel data into variable BMOVB, ALINCEDIMOVAL, BUF2[EDI] ; pick green pixel data into variable GMOVG, ALINCEDIMOVAL, BUF2[EDI] ; pick red pixel data into variable RMOVR, ALINCEDIMOVPIXELCOUNT, EDIMOVTMP, WORD PTR 32H ; 50MOVAL, BMOVCL, 11MULCLADDTMP, AX; 50 + B * 11MOVAL, GMOVCL, 59MULCLADDTMP, AX ; 50 + B * 11 + G * 59MOVAL, RMOVCL, 30MULCLADDTMP, AX ; 50 + B * 11 + G * 59 + R * 30MOVAX, TMPMOVCL, 100DIVCLCALLTOCODE ; to transfer the gray value to its proper corresponding ASCII codeMOVGRAY, AL ; GRAY = (50 + B * 11 + G * 59 + R * 30) / 100; move BUF3 cursor in order to save gray value(which is SI)MOVSI, LASTGRAYMOVBUF3[SI], ALINCSIMOVLASTGRAY, SI; col loop"s relative variable changesMOVEAX, COLCOUNTINCEAXMOVCOLCOUNT, EAX; back to col loopJMPCOLLOOPTOROWLOOP:; call APPENDDATA to append data in area BUF3 into the end of it with the number of BIWIDTH+2CALLAPPENDDATA; back to row loopMOVEAX, ROWCOUNTINCEAXMOVROWCOUNT, EAXJMPROWLOOP;....................................................SHOWERMSG1:LEADX, ERMSG1CALLDISPJMPEXITSHOWERMSG2:LEADX, ERMSG2CALLDISPJMPEXITSHOWERMSG3:LEADX, ERMSG3CALLDISPJMPEXITSHOWERMSG4:LEADX, ERMSG4CALLDISPJMPEXITSHOWERMSG5:LEADX, ERMSG5CALLDISPJMPEXITSHOWERMSG6:LEADX, ERMSG6CALLDISPJMPEXITSHOWERMSG7:LEADX, ERMSG7CALLDISPJMPEXITSHOWERMSG8:LEADX, ERMSG8CALLDISPJMPEXITSHOWERMSG9:LEADX, ERMSG8CALLDISPJMPEXITSHOWERMSG10:LEADX, ERMSG8CALLDISPJMPEXITTOEND:CALLSHOWPROCESS3EXIT:MOVAH, 4CHINT21HMAINENDP;....................................................;....................................................; transfer gray value to its corresponding ASCII ASCII code is saved in ALTOCODEPROCNEARXOREBX, EBXMOVBX, OFFSETASCIICODEMOVAH, 0DIVGRAYCLASSDIVXLATRETTOCODEENDP;....................................................;....................................................; answer of the high 16bit lie in WORD3B, the low 16bit lie in WORD3AADDBIGPROCNEARMOVAX, WORD1AADDAX, WORD2AMOVWORD3A, AXMOVAX, WORD1BADCAX, WORD2BMOVWORD3B, AXRETADDBIGENDP;....................................................;....................................................DISPPROCNEARMOVAH, 09HINT21HRETDISPENDP;....................................................;....................................................NOTICEPROCNEARLEADX, CRLFCALLDISPLEADX, CRLFCALLDISPLEADX, CRLFCALLDISPLEADX, MSG0CALLDISPLEADX, MSG1CALLDISPLEADX, MSG2CALLDISPLEADX, MSG3CALLDISPLEADX, MSG4CALLDISPLEADX, MSG5CALLDISPLEADX, MSG6CALLDISPLEADX, MSG0CALLDISPLEADX, MSG7CALLDISPRETNOTICEENDP;....................................................SHOWPROCESS1PROCNEARLEADX, MSG8CALLDISPRETSHOWPROCESS1 ENDPSHOWPROCESS2PROCNEARLEADX, MSG9CALLDISPLEADX, MSG10CALLDISPLEADX, MSG11CALLDISPRETSHOWPROCESS2 ENDPSHOWPROCESS3PROCNEARLEADX, MSG12CALLDISPLEADX, MSG13CALLDISPLEADX, MSG14CALLDISPLEADX, MSG15CALLDISPLEADX, MSG16CALLDISPLEADX, MSG17CALLDISPRETSHOWPROCESS3 ENDP;....................................................; append data to the end of file (data comes from BUF3)APPENDDATAPROCFARXORAX, AXLEADX, NAMEFMOVAH, 3DH ; open the fileMOVAL, 02HINT21HJNCPOINTERTOENDJMPSHOWERMSG2POINTERTOEND:MOVHANDLE1, AX ; save the file"s codeMOVAH, 42HMOVAL, 02H ; move file"s point to the end of itMOVDX, 0MOVCX, 0MOVBX, HANDLE1INT 21HJNCWRITEDATAJMPSHOWERMSG5 ; if pointer"s movement failedWRITEDATA:MOVAH, 40H ; WRITE DATA INTO FILEMOVBX, HANDLE1MOVCX, ACTWRITTEN ; THE PLANNED BYTE NUMBER OF DATA TO BE WROTELEADX, BUF3INT21HJNCJUDGEDATANUMBERJMPSHOWERMSG3JUDGEDATANUMBER:CMPAX, CX ; COMPARE THE ACTUAL NUMBER AND PLANNED NUMBER OF DATA WRITTEN, TO JUDGE WHETHER WRITTING SUCCEED OR NOTSJERETMAINJMPSHOWERMSG4RETMAIN:MOVAH, 3EH ; close fileMOVBX, HANDLE1INT21HRETAPPENDDATAENDP;....................................................;....................................................; read command lineCMDPROCNEAR; get input into CMDLINEXORAX, AXLEADX, CMDLINEMOVAH, 0AHINT 21HLEADX, CRLFMOVAH, 9INT 21HMOVBL, CMDLINE+1MOVBH, 0MOVBYTE PTR CMDLINE+2[BX], "$"; judge the bmp2txt commandMOVBX, 2CMPCMDLINE[BX], "b"JNESHOWERMSG8INCBXCMPCMDLINE[BX], "m"JNESHOWERMSG8INCBXCMPCMDLINE[BX], "p"JNESHOWERMSG8INCBXCMPCMDLINE[BX], "2"JNESHOWERMSG8INCBXCMPCMDLINE[BX], "t"JNESHOWERMSG8INCBXCMPCMDLINE[BX], "x"JNESHOWERMSG8INCBXCMPCMDLINE[BX], "t"JNESHOWERMSG8INCBXCMPCMDLINE[BX], " "JNESHOWERMSG8; move image file name into variable FNAMEMOVSI, 0loop0:INCBXMOVDL, CMDLINE[BX]MOVBYTE PTR FNAME[SI], DLCMPDL, " "JEp0INCSIJMPloop0p0:MOVFNAME[SI], 00H; move target .txt file name into variable NAMEFMOVSI, 0loop1:INCBXMOVDL, CMDLINE[BX]MOVBYTE PTR NAMEF[SI], DLCMPDL, "$"JEp1INCSIJMPloop1p1:MOVNAMEF[SI], 00HRETCMDENDP;....................................................CODEENDSENDMAIN
上一集:没有了 下一集:
相关文章:&&&&&&&&&&&&&&
最新添加资讯
24小时热门资讯
附近好友搜索君,已阅读到文档的结尾了呢~~
图像处理的信息技术,信息技术处理员,信息技术处理员***,信息技术处理员 题库,信息技术处理员真题,软考信息技术处理员,信息技术处理员考试,信息技术处理员上机,信息技术处理员教程,信息技术处理员领证
扫扫二维码,随身浏览文档
手机或平板扫扫即可继续访问
图像处理的信息技术
举报该文档为侵权文档。
举报该文档含有违规或不良信息。
反馈该文档无法正常浏览。
举报该文档为重复文档。
推荐理由:
将文档分享至:
分享完整地址
文档地址:
粘贴到BBS或博客
flash地址:
支持嵌入FLASH地址的网站使用
html代码:
&embed src='/DocinViewer--144.swf' width='100%' height='600' type=application/x-shockwave-flash ALLOWFULLSCREEN='true' ALLOWSCRIPTACCESS='always'&&/embed&
450px*300px480px*400px650px*490px
支持嵌入HTML代码的网站使用
您的内容已经提交成功
您所提交的内容需要审核后才能发布,请您等待!
3秒自动关闭窗口

参考资料

 

随机推荐