全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2854
推到 Plurk!
推到 Facebook!

關於影像處理~分離RGB之程式設計

尚未結案
Hades3350
一般會員


發表:1
回覆:1
積分:0
註冊:2008-10-01

發送簡訊給我
#1 引用回覆 回覆 發表時間:2008-10-03 00:22:44 IP:140.130.xxx.xxx 訂閱
目的:

把1張bmp(512*512)用成24張bitplane

構想:

我想把檔頭全部寫回24張圖去

接下來用3個buffer分別存R.G.B的值

假設除以3餘0為B,1為G,2為R,然後再做運算

然後就把值寫回每一張圖去

最後~

會出現24張圖

**可是我的這個程式跑不動

不知道是哪裡出了錯

想請各位厲害的大大幫我找一下

謝謝~

-----------------------------以下是我的程式碼-------------------------------

#include
#include
#define d 0
int main()
{
FILE *orimage=fopen("A.bmp","rb");
unsigned char buffer[786486];
int a,b,c,e,f,g,n,temp1,temp2,temp3,temp4,temp5,temp6;
char miko1[c],miko2[e],miko3[f],miko4[g];

for(a=0;a<786486;a )
buffer[a]=getc(orimage);

FILE *Bplane0_B=fopen("A0_B.bmp","wb");
FILE *Bplane1_B=fopen("A1_B.bmp","wb");
FILE *Bplane2_B=fopen("A2_B.bmp","wb");
FILE *Bplane3_B=fopen("A3_B.bmp","wb");
FILE *Bplane4_B=fopen("A4_B.bmp","wb");
FILE *Bplane5_B=fopen("A5_B.bmp","wb");
FILE *Bplane6_B=fopen("A6_B.bmp","wb");
FILE *Bplane7_B=fopen("A7_B.bmp","wb");

FILE *Bplane0_G=fopen("A0_G.bmp","wb");
FILE *Bplane1_G=fopen("A1_G.bmp","wb");
FILE *Bplane2_G=fopen("A2_G.bmp","wb");
FILE *Bplane3_G=fopen("A3_G.bmp","wb");
FILE *Bplane4_G=fopen("A4_G.bmp","wb");
FILE *Bplane5_G=fopen("A5_G.bmp","wb");
FILE *Bplane6_G=fopen("A6_G.bmp","wb");
FILE *Bplane7_G=fopen("A7_G.bmp","wb");

FILE *Bplane0_R=fopen("A0_R.bmp","wb");
FILE *Bplane1_R=fopen("A1_R.bmp","wb");
FILE *Bplane2_R=fopen("A2_R.bmp","wb");
FILE *Bplane3_R=fopen("A3_R.bmp","wb");
FILE *Bplane4_R=fopen("A4_R.bmp","wb");
FILE *Bplane5_R=fopen("A5_R.bmp","wb");
FILE *Bplane6_R=fopen("A6_R.bmp","wb");
FILE *Bplane7_R=fopen("A7_R.bmp","wb");

for(b=0;b<54;b )
{
fprintf(Bplane7_B,"%c",buffer[b]);
fprintf(Bplane6_B,"%c",buffer[b]);
fprintf(Bplane5_B,"%c",buffer[b]);
fprintf(Bplane4_B,"%c",buffer[b]);
fprintf(Bplane3_B,"%c",buffer[b]);
fprintf(Bplane2_B,"%c",buffer[b]);
fprintf(Bplane1_B,"%c",buffer[b]);
fprintf(Bplane0_B,"%c",buffer[b]);

fprintf(Bplane7_G,"%c",buffer[b]);
fprintf(Bplane6_G,"%c",buffer[b]);
fprintf(Bplane5_G,"%c",buffer[b]);
fprintf(Bplane4_G,"%c",buffer[b]);
fprintf(Bplane3_G,"%c",buffer[b]);
fprintf(Bplane2_G,"%c",buffer[b]);
fprintf(Bplane1_G,"%c",buffer[b]);
fprintf(Bplane0_G,"%c",buffer[b]);

fprintf(Bplane7_R,"%c",buffer[b]);
fprintf(Bplane6_R,"%c",buffer[b]);
fprintf(Bplane5_R,"%c",buffer[b]);
fprintf(Bplane4_R,"%c",buffer[b]);
fprintf(Bplane3_R,"%c",buffer[b]);
fprintf(Bplane2_R,"%c",buffer[b]);
fprintf(Bplane1_R,"%c",buffer[b]);
fprintf(Bplane0_R,"%c",buffer[b]);
}

for(c=54;c<786486;c )
{
if(c%3==0)
{
miko2[e]=miko1[c];
// printf( "%d" "\n", miko2[e]);
e ;
}
else if(c%3==1)
{
miko3[f]=miko1[c];
f ;
}
else if(c%3==2)
{
miko4[g]=miko1[c];
g ;
}
}

for(e=0;e<(512*512);e )
{
for(n=1;n<=8;n )
{
temp1=miko2[e]%2;
temp2=miko2[e]/2;
miko2[e]=temp2;

if(temp1==1)
temp1=255;
else
temp1=0;

switch(n)
{
case 1:
fprintf(Bplane7_B,"%c",char(temp1));
fprintf(Bplane7_B,"%c",d);
fprintf(Bplane7_B,"%c",d);
break;
case 2:
fprintf(Bplane6_B,"%c",char(temp1));
fprintf(Bplane6_B,"%c",d);
fprintf(Bplane6_B,"%c",d);
break;
case 3:
fprintf(Bplane5_B,"%c",char(temp1));
fprintf(Bplane5_B,"%c",d);
fprintf(Bplane5_B,"%c",d);
break;
case 4:
fprintf(Bplane4_B,"%c",char(temp1));
fprintf(Bplane4_B,"%c",d);
fprintf(Bplane4_B,"%c",d);
break;
case 5:
fprintf(Bplane3_B,"%c",char(temp1));
fprintf(Bplane3_B,"%c",d);
fprintf(Bplane3_B,"%c",d);
break;
case 6:
fprintf(Bplane2_B,"%c",char(temp1));
fprintf(Bplane2_B,"%c",d);
fprintf(Bplane2_B,"%c",d);
break;
case 7:
fprintf(Bplane1_B,"%c",char(temp1));
fprintf(Bplane1_B,"%c",d);
fprintf(Bplane1_B,"%c",d);
break;
case 8:
fprintf(Bplane0_B,"%c",char(temp1));
fprintf(Bplane0_B,"%c",d);
fprintf(Bplane0_B,"%c",d);
break;
}
}
}

for(f=0;f<(512*512);f )
{
for(n=1;n<=8;n )
{
temp3=miko3[f]%2;
temp4=miko3[f]/2;
miko3[f]=temp4;

if(temp3==1)
temp3=255;
else
temp3=0;
switch(n)
{
case 1:
fprintf(Bplane7_G,"%c",d);
fprintf(Bplane7_G,"%c",char(temp3));
fprintf(Bplane7_G,"%c",d);
break;
case 2:
fprintf(Bplane6_G,"%c",d);
fprintf(Bplane6_G,"%c",char(temp3));
fprintf(Bplane6_G,"%c",d);
break;
case 3:
fprintf(Bplane5_G,"%c",d);
fprintf(Bplane5_G,"%c",char(temp3));
fprintf(Bplane5_G,"%c",d);
break;
case 4:
fprintf(Bplane4_G,"%c",d);
fprintf(Bplane4_G,"%c",char(temp3));
fprintf(Bplane4_G,"%c",d);
break;
case 5:
fprintf(Bplane3_G,"%c",d);
fprintf(Bplane3_G,"%c",char(temp3));
fprintf(Bplane3_G,"%c",d);
break;
case 6:
fprintf(Bplane2_G,"%c",d);
fprintf(Bplane2_G,"%c",char(temp3));
fprintf(Bplane2_G,"%c",d);
break;
case 7:
fprintf(Bplane1_G,"%c",d);
fprintf(Bplane1_G,"%c",char(temp3));
fprintf(Bplane1_G,"%c",d);
break;
case 8:
fprintf(Bplane0_G,"%c",d);
fprintf(Bplane0_G,"%c",char(temp3));
fprintf(Bplane0_G,"%c",d);
break;
}
}
}

for(g=0;g<(512*512);g )
{
for(n=1;n<=8;n )
{
temp5=miko4[g]%2;
temp6=miko4[g]/2;
miko4[g]=temp6;

if(temp5==1)
temp5=255;
else
temp5=0;
switch(n)
{
case 1:
fprintf(Bplane7_R,"%c",d);
fprintf(Bplane7_R,"%c",d);
fprintf(Bplane7_R,"%c",char(temp5));
break;
case 2:
fprintf(Bplane6_R,"%c",d);
fprintf(Bplane6_R,"%c",d);
fprintf(Bplane6_R,"%c",char(temp5));
break;
case 3:
fprintf(Bplane5_R,"%c",d);
fprintf(Bplane5_R,"%c",d);
fprintf(Bplane5_R,"%c",char(temp5));
break;
case 4:
fprintf(Bplane4_R,"%c",d);
fprintf(Bplane4_R,"%c",d);
fprintf(Bplane4_R,"%c",char(temp5));
break;
case 5:
fprintf(Bplane3_R,"%c",d);
fprintf(Bplane3_R,"%c",d);
fprintf(Bplane3_R,"%c",char(temp5));
break;
case 6:
fprintf(Bplane2_R,"%c",d);
fprintf(Bplane2_R,"%c",d);
fprintf(Bplane2_R,"%c",char(temp5));
break;
case 7:
fprintf(Bplane1_R,"%c",d);
fprintf(Bplane1_R,"%c",d);
fprintf(Bplane1_R,"%c",char(temp5));
break;
case 8:
fprintf(Bplane0_R,"%c",d);
fprintf(Bplane0_R,"%c",d);
fprintf(Bplane0_R,"%c",char(temp5));
break;
}
}
}

}
andyshooter
一般會員


發表:6
回覆:10
積分:3
註冊:2009-04-01

發送簡訊給我
#2 引用回覆 回覆 發表時間:2009-04-01 13:05:38 IP:203.74.xxx.xxx 訂閱
請問能將其分離成

原圖*1 R*1 G*1 B*1 = 4張

我是用BCB程式

請問能將這位大大的程式簡化成只開出4張圖嗎???
Hades3350
一般會員


發表:1
回覆:1
積分:0
註冊:2008-10-01

發送簡訊給我
#3 引用回覆 回覆 發表時間:2009-04-02 10:58:10 IP:114.42.xxx.xxx 訂閱
根據...
我後來有把我上面的那個程式寫出來的感想
你說的那樣當然是可以囉!!!
重點就看你會不會改啦~
ikk
尊榮會員


發表:4
回覆:413
積分:768
註冊:2003-06-30

發送簡訊給我
#4 引用回覆 回覆 發表時間:2009-04-03 13:59:15 IP:163.28.xxx.xxx 訂閱
char miko1[c],miko2[e],miko3[f],miko4[g];  


c, e, f, g 都沒初始值.....
------
FPGA驗證, FPGA開發平台, http://smims.com
andyshooter
一般會員


發表:6
回覆:10
積分:3
註冊:2009-04-01

發送簡訊給我
#5 引用回覆 回覆 發表時間:2009-04-03 19:28:54 IP:219.81.xxx.xxx 訂閱
這樣問可能有點冒昧

但是可以請你改一下嗎

因為我還蠻急需的

抱歉
系統時間:2024-04-19 21:22:47
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!