Képfeldolgozási módszerek – Diva3D kódolás
Kép mérete:
[0][0] (bal felső)
|
[height-1][width-1] (jobb alsó)
Képpontok
koordinátájának hivatkozása:
[j-2][i-2] |
[j-2][i-1] |
[j-2][i] |
[j-2][i+1] |
[j-2][i+2] |
[j-1][i-2] |
[j-1][i-1] |
[j-1][i] |
[j-1][i+1] |
[j-1][i+2] |
[j][i-2] |
[j][i-1] |
[j][i] |
[j][i+1] |
[j][i+2] |
[j+1][i-2] |
[j+1][i-1] |
[j+1][i] |
[j+1][i+1] |
[j+1][i+2] |
[j+2][i-2] |
[j+2][i-1] |
[j+2][i] |
[j+2][i+1] |
[j+2][i+2] |
Képpont elérése:
Volume->mem.ucval[color][frame][coordy][coordx]
color: az RGB
színcsatorna, értékkészlete: 0..2
(0=R(ed), 1=G(reen), 2=B(lue))
frame: a
videoframe száma (indexe), értékkészlete: 0..
Vol->depth-1
coordy: a
képpont függőleges koordinátája, értékkészlete: 0..
Vol->height-1
coordy: a
képpont vízszintes koordinátája, értékkészlete: 0..
Vol->width-1
Volume->mem.ucval[color][frame][coordy][coordx]
értékkészlete: 0..255 (8
bites grayscale/24 bites RGB)
MessageBox
használata (hibakereséshez):
MessageBox
(NULL,"Message","Title", MB_OK);
Vagy:
char
demo_string[100];
int x;
...
sprintf(demo_string,"%d
",x);
MessageBox
(NULL,demo_string,"Title", MB_OK);
Mai:
int
cont_dir=0; /* 0 up, 1 left, 2 down, 3 right */
acti=sti;
actj=stj;
cont_dir=0;
reduction_rate=4;
// startin pixel is highlited and marked as
visited
outSil->mem.ucval[0][ks][actj][acti]=255;
outSil->mem.ucval[1][ks][actj][acti]=255;
outSil->mem.ucval[2][ks][actj][acti]=255;
visited[actj][acti]=1;
reduce_counter=1; //starting the counter
for reduction rate
while (cont_finish==0) //while we do not
reach the starting point
{
if (reduce_counter==reduction_rate)
(reduce_counter=0);
switch (cont_dir)
{
case 0: // UP direction for the
boundary vector
if
(inSil->mem.ucval[0][ks][actj-1][acti-1]!=0) // checking upper left
neighbour
{
actj=actj-1;
acti=acti-1;
cont_dir=1;
if
((reduce_counter==0) && (visited[actj][acti]==0))
{
outSil->mem.ucval[0][ks][actj][acti]=255;
outSil->mem.ucval[1][ks][actj][acti]=255;
outSil->mem.ucval[2][ks][actj][acti]=255;
}
if ((actj==stj)
&& (acti==sti)) (cont_finish=1); // we reached the starting point and
STOP
if
(visited[actj][acti]==0) (reduce_counter=reduce_counter+1); // increasing the
reduction counter
visited[actj][acti]=1;
//mark the pixel as visited
}
else if
(inSil->mem.ucval[0][ks][actj-1][acti]!=0) // checking upper neighbour
{
actj=actj-1;
acti=acti;
cont_dir=0;
if
((reduce_counter==0) && (visited[actj][acti]==0))
{
outSil->mem.ucval[0][ks][actj][acti]=255;
outSil->mem.ucval[1][ks][actj][acti]=255;
outSil->mem.ucval[2][ks][actj][acti]=255;
}
if ((actj==stj)
&& (acti==sti)) (cont_finish=1); // we reached the starting point and
STOP
if
(visited[actj][acti]==0) (reduce_counter=reduce_counter+1); // increasing the
reduction counter
visited[actj][acti]=1;
//mark the pixel as visited
}
else
{
cont_dir=3; // turn
right simply (this pixel has been processed yet)
}
break;
case 1: // LEFT direction for the
boundary vector
if
(inSil->mem.ucval[0][ks][actj+1][acti-1]!=0)
{
actj=actj+1;
acti=acti-1;
cont_dir=2;
if
((reduce_counter==0) && (visited[actj][acti]==0))
{
outSil->mem.ucval[0][ks][actj][acti]=255;
outSil->mem.ucval[1][ks][actj][acti]=255;
outSil->mem.ucval[2][ks][actj][acti]=255;
}
if ((actj==stj)
&& (acti==sti)) (cont_finish=1); // we reached the starting point and
STOP
if
(visited[actj][acti]==0) (reduce_counter=reduce_counter+1); // increasing the
reduction counter
visited[actj][acti]=1;
//mark the pixel as visited
}
else if
(inSil->mem.ucval[0][ks][actj][acti-1]!=0)
{
actj=actj;
acti=acti-1;
cont_dir=1;
if
((reduce_counter==0) && (visited[actj][acti]==0))
{
outSil->mem.ucval[0][ks][actj][acti]=255;
outSil->mem.ucval[1][ks][actj][acti]=255;
outSil->mem.ucval[2][ks][actj][acti]=255;
}
if ((actj==stj)
&& (acti==sti)) (cont_finish=1); // we reached the starting point and
STOP
if (visited[actj][acti]==0)
(reduce_counter=reduce_counter+1); // increasing the reduction counter
visited[actj][acti]=1;
//mark the pixel as visited
}
else
{
cont_dir=0;
}
break;
case 2: // DOWN direction for
the boundary vector
if
(inSil->mem.ucval[0][ks][actj+1][acti+1]!=0)
{
actj=actj+1;
acti=acti+1;
cont_dir=3;
...