Re: [問題]影像fprintf 問題已回收

看板MATLAB作者 (灰狼)時間14年前 (2011/05/08 17:59), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
※ 引述《a1013944 (ㄚ春)》之銘言: : 由於最近要分析一張圖 每個點的RGB值 : 所以小弟自學matlab(它實在太強大了) : 不過在輸出txt檔 有一些問題 : 其實我想要輸出 為 : 8h0_0 :R=ff : 8h0_0 :G=ff : 8h0_0 :B=ff : 8h0_1 :R=ff : 8h0_1 :G=ff : 8h0_1 :B=ff : . : . : . : . : 可是在 8h0_0 :R=ff 和 8h0_0 :G=ff 中間 都會出現一堆 8h3f_3f :R=3f : ....之類的數值 : 可是感覺 那是多存進去的 但不知道為什麼 會存這些進去 : 希望大家可以幫我找出問題 感謝 : 以下附程式碼 : clear all; : %load my.bmp; : in_image = imread('in.bmp'); : %figure,imshow(x),pixvel on : size(in_image); ^^^^^^^^^^^^^^ 這行讀取size感覺好像沒有用= =? : in_image_txt = fopen('a.txt', 'w'); : for v = 0:15, : for h = 0:15, : for color = 1:3, : if(color==1), : n1=in_image(:,:,color) ; ^^^^^^^^^^^ 你假如是要讀其中一個pixel的值 應該是用 (h,v,color) 而且matlab在index是從1開始 所以15*15的圖 要用 v=1:15 h=1:15 : fprintf(in_image_txt, '8h%hx_%hx :R=%hx \r\n',v,h,n1); : end : if(color==2), : n2=in_image(:,:,color) ; : fprintf(in_image_txt, '8h%hx_%hx :G=%hx \r\n',v,h,n2); : end : if(color==3), : n3=in_image(:,:,color); : fprintf(in_image_txt, '8h%hx_%hx :B=%hx \r\n',v,h,n3); : %fprintf(in_image_txt,'\r\n'); : end : end : end : end : fclose(in_image_txt); : type a.txt 另外你的迴圈寫得很亂 你些跑color迴圈 又來判斷color = 1 or 2 or 3 不如直接拔掉color迴圈 用color=1 color=2 color 來取代if那個判斷式 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.113.13.125
文章代碼(AID): #1DnccTwj (MATLAB)
文章代碼(AID): #1DnccTwj (MATLAB)