Thread View: comp.soft-sys.khoros
2 messages
2 total messages
Started by John C. Schultz
Fri, 22 Jan 1993 16:35
Bug? and correction in lvmdilate
Author: John C. Schultz
Date: Fri, 22 Jan 1993 16:35
Date: Fri, 22 Jan 1993 16:35
157 lines
5540 bytes
5540 bytes
lvmdilate.c (src/vipl/Lib) produces a result which is shifted wrt to
the original image by 1/2 of the kernel dimensions. This is a bug in
my opinion.
The following diff can be applied with patch to fix lvmdilate.c
vmdilate will now work exactly for odd kernels and shift the image
down and to the right by 1 pixel for even kernels. Note that this may
not be compatible with vmerode, vmcdilate, ... but the patched version
is correct in IMHO.
e.g.
00000 00000 00000
00000 111 01110 00000
00100 w 111 will generate 01110 rather than 00111
00000 111 01110 00111
00000 00000 00111
00000 00000
00000 1111 01111
00100 w 1111 will generate 01111
00000 1111 01111
00000 00000
*** /usr/khoros/src/vipl/Lib/lvmdilate.c Fri Mar 20 17:04:10 1992
--- lvmdilate.c Fri Jan 22 10:05:34 1993
***************
*** 209,215 ****
c3 = result;
k = nc * nr; /* Normal operation count */
! for (j=0;j<k;j++) *(c3 +j)=0;
for (i=0;i<nr;i++) {
--- 209,215 ----
c3 = result;
k = nc * nr; /* Normal operation count */
! bzero(c3, k * sizeof(unsigned char));
for (i=0;i<nr;i++) {
***************
*** 218,229 ****
if (*(c1+i*nc+j) != 0) {
! for (ii=0;ii<kernr;ii++) {
- iii = i+ii+starti;
if (iii<0 || iii>=nr) continue;
! for (jj=0; jj<kernc; jj++) {
! jjj = j+jj+startj;
if ( jjj>=0 && jjj<nc )
if (*(c2+ii*kernc+jj) != 0)
*(c3+ iii*nc + jjj) = 255;
--- 218,230 ----
if (*(c1+i*nc+j) != 0) {
! for (ii = 0; ii < kernr; ii++) {
! iii = i+ii+starti + ((kernr & 0X01) ? -kernr/2 : -kernc/2 + 1);
if (iii<0 || iii>=nr) continue;
! for (jj = 0; jj < kernc; jj++) {
!
! jjj = j+jj+startj + ((kernc & 0X01) ? -kernc/2 : -kernc/2 + 1);
if ( jjj>=0 && jjj<nc )
if (*(c2+ii*kernc+jj) != 0)
*(c3+ iii*nc + jjj) = 255;
***************
*** 234,240 ****
}
c1 = (unsigned char *) image->imagedata;
c3 = result;
! for (i=0;i<k;i++) *c1++ = *c3++;
free(result);
--- 235,241 ----
}
c1 = (unsigned char *) image->imagedata;
c3 = result;
! bcopy(c3, c1, k * sizeof(unsigned char));
free(result);*** lvmdilate.c Fri Jan 22 10:05:34 1993
--- /usr/khoros/src/vipl/Lib/lvmdilate.c Fri Mar 20 17:04:10 1992
***************
*** 209,215 ****
c3 = result;
k = nc * nr; /* Normal operation count */
! bzero(c3, k * sizeof(unsigned char));
for (i=0;i<nr;i++) {
--- 209,215 ----
c3 = result;
k = nc * nr; /* Normal operation count */
! for (j=0;j<k;j++) *(c3 +j)=0;
for (i=0;i<nr;i++) {
***************
*** 218,230 ****
if (*(c1+i*nc+j) != 0) {
! for (ii = 0; ii < kernr; ii++) {
! iii = i+ii+starti + ((kernr & 0X01) ? -kernr/2 : -kernc/2 + 1);
if (iii<0 || iii>=nr) continue;
! for (jj = 0; jj < kernc; jj++) {
!
! jjj = j+jj+startj + ((kernc & 0X01) ? -kernc/2 : -kernc/2 + 1);
if ( jjj>=0 && jjj<nc )
if (*(c2+ii*kernc+jj) != 0)
*(c3+ iii*nc + jjj) = 255;
--- 218,229 ----
if (*(c1+i*nc+j) != 0) {
! for (ii=0;ii<kernr;ii++) {
+ iii = i+ii+starti;
if (iii<0 || iii>=nr) continue;
! for (jj=0; jj<kernc; jj++) {
! jjj = j+jj+startj;
if ( jjj>=0 && jjj<nc )
if (*(c2+ii*kernc+jj) != 0)
*(c3+ iii*nc + jjj) = 255;
***************
*** 235,241 ****
}
c1 = (unsigned char *) image->imagedata;
c3 = result;
! bcopy(c3, c1, k * sizeof(unsigned char));
free(result);
--- 234,240 ----
}
c1 = (unsigned char *) image->imagedata;
c3 = result;
! for (i=0;i<k;i++) *c1++ = *c3++;
free(result);
--
John C. Schultz +1 (612) 733-4047 schultz@halley.serc.3m.com
How to include the taste of Glendronach in a multi-media system?
Re: Bug? and correction in lvmdilate
Author: John C. Schultz
Date: Fri, 22 Jan 1993 16:43
Date: Fri, 22 Jan 1993 16:43
5 lines
804 bytes
804 bytes
Whoops, the patch makes the corrected file lvmdilate.c.orig rather than lvmdilate.c - please rename by hand. Sorry. -- John C. Schultz +1 (612) 733-4047 schultz@halley.serc.3m.com How to include the taste of Glendronach in a multi-media system?
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads