diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2022-02-26 21:57:16 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2022-02-26 21:57:16 +0000 |
commit | 2c02bc8292a5adab9a66c84967a2b7be383b3edf (patch) | |
tree | 628123cfdca5289e7f14ce9389d33ef7e89dca99 /other | |
parent | a1bab3231dddabd85a185715a9eeb5002f677da3 (diff) | |
download | netpbm-mirror-2c02bc8292a5adab9a66c84967a2b7be383b3edf.tar.gz netpbm-mirror-2c02bc8292a5adab9a66c84967a2b7be383b3edf.tar.xz netpbm-mirror-2c02bc8292a5adab9a66c84967a2b7be383b3edf.zip |
Fix bogus colors at edges
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@4281 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'other')
-rw-r--r-- | other/pambayer.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/other/pambayer.c b/other/pambayer.c index 703f208e..ba1322c2 100644 --- a/other/pambayer.c +++ b/other/pambayer.c @@ -109,6 +109,54 @@ parseCommandLine(int argc, const char ** argv, static void +clearTuples(const struct pam * const pamP, + tuple ** const outtuples) { +/*---------------------------------------------------------------------------- + Make tuples at the edge that may not get set to anything by the normal + computation of the bayer pattern black. +-----------------------------------------------------------------------------*/ + if (pamP->height <= 4 || pamP->width <= 4) { + unsigned int row; + + for (row = 0; row < pamP->height; ++row) { + unsigned int col; + for (col = 0; col < pamP->width; ++col) { + unsigned int plane; + for (plane = 0; plane < pamP->depth; ++plane) + outtuples[row][col][plane] = 0; + } + } + } else { + unsigned int col; + unsigned int row; + + for (col = 0; col < pamP->width; ++col) { + unsigned int plane; + + for (plane = 0; plane < pamP->depth; ++plane) { + outtuples[0][col][plane] = 0; + outtuples[1][col][plane] = 0; + outtuples[pamP->height-2][col][plane] = 0; + outtuples[pamP->height-1][col][plane] = 0; + } + + for (row = 2; row < pamP->height - 2; ++row) { + unsigned int plane; + + for (plane = 0; plane < pamP->depth; ++plane) { + outtuples[row][0][plane] = 0; + outtuples[row][1][plane] = 0; + outtuples[row][pamP->width-2][plane] = 0; + outtuples[row][pamP->width-1][plane] = 0; + } + } + } + } +} + + + +static void calc4(const struct pam * const pamP, tuple ** const intuples, tuple ** const outtuples, @@ -380,6 +428,7 @@ actionTableForType(enum BayerType const bayerType) { static void calcImage(struct pam * const inpamP, tuple ** const intuples, + struct pam * const outpamP, tuple ** const outtuples, enum BayerType const bayerType, bool const wantNoInterpolate) { @@ -389,6 +438,8 @@ calcImage(struct pam * const inpamP, unsigned int plane; + clearTuples(outpamP, outtuples); + for (plane = 0; plane < 3; ++plane) { struct CompAction const compAction = compActionTable[plane]; @@ -425,7 +476,7 @@ main(int argc, const char **argv) { if (cmdline.subchannel) calcSubchannel(&inpam, intuples, outtuples, cmdline.bayerType); else - calcImage(&inpam, intuples, outtuples,cmdline.bayerType, + calcImage(&inpam, intuples, &outpam, outtuples,cmdline.bayerType, !!cmdline.nointerpolate); pnm_writepam(&outpam, outtuples); |