cscon113@uoft02.utoledo.edu (07/25/90)
I am looking for a package to brighten an image. I have pbmplus, FBM and several conversion routines. I can't seem to find anything to use to brighten an image that won't leaveblack spots where the darkest parts of the image were. Any help appreciated, James H. Lewallen cscon113 cscon113@uoft02.utoledo.edu
macphed@herald.usask.ca (Ian MacPhedran) (08/01/90)
From article <1990Jul25.110057.1259@uoft02.utoledo.edu>, by cscon113@uoft02.utoledo.edu: > > I am looking for a package to brighten an image. I have pbmplus, FBM > and several conversion routines. I can't seem to find anything to > use to brighten an image that won't leaveblack spots where the darkest > parts of the image were. > > Any help appreciated, > James H. Lewallen James; Why not use ppmarith to add a constant value image to your image? This avoids the problem of having zero-value pixels. As well, you could add a low value (say 2 with a maxval of 255), and then multiply the image by a constant value. This would give a better spread to the colour map, yet still have no black spots in the final image. (Note - I haven't tried this. I prefer to stretch the colourmap, as pgmnorm does, so that the darker pixels are still dark to give better contrast.) Ian. Ian MacPhedran, Engineering Computer Centre, University of Saskatchewan. 2B13 Engineering Building, U. of S. Campus, Saskatoon, Sask., CANADA S7N 0W0 macphed@dvinci.USask.CA macphedran@sask.USask.CA macphedran@sask.BITNET -- Ian MacPhedran, Engineering Computer Centre, University of Saskatchewan. 2B13 Engineering Building, U. of S. Campus, Saskatoon, Sask., CANADA S7N 0W0 macphed@dvinci.USask.CA macphedran@sask.USask.CA macphedran@sask.BITNET
nmm@mcquaig.UUCP (Neil M. McQuaig) (08/02/90)
In article <1990Jul31.233156.11888@herald.usask.ca> you write: >From article <1990Jul25.110057.1259@uoft02.utoledo.edu>, by cscon113@uoft02.utoledo.edu: >> >> I am looking for a package to brighten an image. I have pbmplus, FBM >> and several conversion routines. I can't seem to find anything to >> use to brighten an image that won't leaveblack spots where the darkest >> parts of the image were. >> >> Any help appreciated, >> James H. Lewallen >James; > >Why not use ppmarith to add a constant value image to your image? This >avoids the problem of having zero-value pixels. As well, you could add >a low value (say 2 with a maxval of 255), and then multiply the image >by a constant value. This would give a better spread to the colour map, >yet still have no black spots in the final image. Another alternative: I needed a ppm program to write targa files. When I finished I found that many of the colors on the targa were too dim. The scaling bunched the rgb values into a small range at the low end of the spectrum. The solution I use is as follows and has worked ok so far. 1. Create a ppm histogram. 2. Scan the histogram to find the real max pixel value for red, green, or blue. 3. Use that value as the scaling factor to spread the colors through the output devices legal range (5 bits on a targa 16). This has the advantage that black stays black and does not turn to gray as it would if a constant were added to each pixel value. The code fragment below are from my ppmtotga routines. Hope this helps. If its dumb, I'm all ears. pixels = ppm_readppm( ifd, &cols, &rows, &maxval ); pm_close( ifd ); if (debug) fprintf(stderr,"maxval=%d MAXCOLORS=%d\n", maxval, MAXCOLORS); /* Figure out the colormap. */ if (tga_scale) { if (debug) fprintf( stderr, "Computing colormap..." ); chv = ppm_computecolorhist( pixels, cols, rows, MAXCOLORS, &colors ); if ( chv == (colorhist_vector) 0 ) pm_error("too many colors - run through 'ppmquant 32768'", 0,0,0,0,0 ); if (debug) fprintf( stderr, " Done. %d colors found.)\n", colors ); /* get the max pixel value to use for scaling the colors */ for ( i = 0; i < colors; i++ ) { real_maxval = max(PPM_GETR( chv[i].color ), real_maxval); real_maxval = max(PPM_GETG( chv[i].color ), real_maxval); real_maxval = max(PPM_GETB( chv[i].color ), real_maxval); } ppm_freecolorhist(chv); if (debug) { fprintf( stderr, " Real maxval = %d\n", real_maxval); fflush (stderr); } } else { real_maxval = maxval; } ... put_pixel( ofd, pxl ) FILE *ofd; pixel pxl; { static pixval Red, Grn, Blu; static unsigned char ch[2]; /* Convert ppm map, scale to 5 bits to Targa and write it out */ Red = (int) PPM_GETR(pxl) * tga_maxval/real_maxval; Grn = (int) PPM_GETG(pxl) * tga_maxval/real_maxval; Blu = (int) PPM_GETB(pxl) * tga_maxval/real_maxval; ch[0] = (unsigned char) ((Blu & 0x1F) | ((Grn << 5) & 0xE0)); ch[1] = (unsigned char) (((Red << 2) & 0x7C) | ((Grn >> 3) & 0x03)); fputc(ch[0], ofd); fputc(ch[1], ofd); } -- Neil M. McQuaig 344 Millicent Way, Shreveport, LA 71106 VOICE: (318)868-5611 UUCP: mcquaig!nmm (318)865-1051 or uunet!mcquaig!nmm
harry@neuron1.Jpl.Nasa.Gov (Harry Langenbacher) (08/03/90)
I use this alias on my Sun to brighten rasterfiles, it can be adapted to any formats handled by fbm software. alias rasbrightenfbm 'nice +15 unmap<\!^:r.ras|fbnorm \!:2 \!:3|fbquant -S -c\!:4>\!^:r.\!:2.\!:3.\!:4.ras&' example: rasbrightenfbm nasalogo.ras 0 200 256 does this: unmap < nasalogo.ras | fbnorm 0 200 | fbquant -S -c256 > nasalogo.0.200.256.ras producing a 256 color rasterfile, with all pixels brightened by a factor of 256/200 , right? - Harry Langenbacher 818-354-9513 harry%neuron1@jpl-mil.jpl.nasa.gov harry@neuron1.jpl.nasa.gov 128.149.12.7