Changeset 11613

Show
Ignore:
Timestamp:
07/12/08 14:24:54 (7 weeks ago)
Author:
cristy
Message:
 
Location:
ImageMagick/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • ImageMagick/trunk/magick/color.c

    r11443 r11613  
    642642      break; 
    643643    } 
    644     case OpacityChannel: 
    645     { 
    646       color=pixel->opacity; 
     644    case AlphaChannel: 
     645    { 
     646      color=QuantumRange-pixel->opacity; 
    647647      break; 
    648648    } 
     
    13221322    { 
    13231323      (void) ConcatenateMagickString(tuple,",",MaxTextExtent); 
    1324       ConcatenateColorComponent(&color,OpacityChannel,SVGCompliance,tuple); 
     1324      ConcatenateColorComponent(&color,AlphaChannel,SVGCompliance,tuple); 
    13251325    } 
    13261326  (void) ConcatenateMagickString(tuple,")",MaxTextExtent); 
     
    15991599      { 
    16001600        (void) ConcatenateMagickString(tuple,",",MaxTextExtent); 
    1601         ConcatenateColorComponent(&pixel,OpacityChannel,X11Compliance, 
    1602           tuple); 
     1601        ConcatenateColorComponent(&pixel,OpacityChannel,X11Compliance,tuple); 
    16031602      } 
    16041603    (void) ConcatenateMagickString(tuple,")",MaxTextExtent); 
  • ImageMagick/trunk/magick/shear.c

    r11601 r11613  
    4747*/ 
    4848#include "magick/studio.h" 
     49#include "magick/artifact.h" 
    4950#include "magick/blob-private.h" 
    5051#include "magick/cache-private.h" 
     
    580581  off_t 
    581582    i; 
    582      
     583 
    583584  unsigned short 
    584     value;  
    585      
     585    value; 
     586 
    586587  i=(off_t) radon_info->height*x+y; 
    587   if ((i < 0) ||  
    588       ((i*sizeof(*radon_info->cells)) >= radon_info->length)) 
     588  if ((i < 0) || 
     589      ((MagickSizeType) (i*sizeof(*radon_info->cells)) >= radon_info->length)) 
    589590    return(0); 
    590591  if (radon_info->type != DiskCache) 
     
    606607 
    607608  i=(off_t) radon_info->height*x+y; 
    608   if ((i < 0) ||  
    609       ((i*sizeof(*radon_info->cells)) >= radon_info->length)) 
     609  if ((i < 0) || 
     610      ((MagickSizeType) (i*sizeof(*radon_info->cells)) >= radon_info->length)) 
    610611    return(0); 
    611612  if (radon_info->type != DiskCache) 
     
    651652 
    652653      unsigned short 
    653         value; 
     654        cell; 
    654655 
    655656      for (i=0; i < (long) step; i++) 
    656657      { 
    657         for (y=0; y < (long) p->height; y++) 
     658        for (y=0; y < (long) (p->height-i-1); y++) 
    658659        { 
    659           value=GetRadonCell(p,x+i,y); 
    660           (void) SetRadonCell(q,x+2*i,y,value+GetRadonCell(p,x+i+step,y+i)); 
    661           (void) SetRadonCell(q,x+2*i+1,y,value+GetRadonCell(p,x+i+step,y+i+1)); 
     660          cell=GetRadonCell(p,x+i,y); 
     661          (void) SetRadonCell(q,x+2*i,y,cell+GetRadonCell(p,x+i+step,y+i)); 
     662          (void) SetRadonCell(q,x+2*i+1,y,cell+GetRadonCell(p,x+i+step,y+i+1)); 
     663        } 
     664        for ( ; y < (long) (p->height-i); y++) 
     665        { 
     666          cell=GetRadonCell(p,x+i,y); 
     667          (void) SetRadonCell(q,x+2*i,y,cell+GetRadonCell(p,x+i+step,y+i)); 
     668          (void) SetRadonCell(q,x+2*i+1,y,cell); 
     669        } 
     670        for ( ; y < (long) p->height; y++) 
     671        { 
     672          cell=GetRadonCell(p,x+i,y); 
     673          (void) SetRadonCell(q,x+2*i,y,cell); 
     674          (void) SetRadonCell(q,x+2*i+1,y,cell); 
    662675        } 
    663676      } 
     
    771784    bit=0; 
    772785    byte=0; 
    773     i=0; 
     786    i=(long) (image->columns+7)/8; 
    774787    for (x=0; x < (long) image->columns; x++) 
    775788    { 
    776789      byte<<=1; 
    777       if ((p->red < threshold) || (p->green < threshold) || 
    778           (p->blue < threshold)) 
     790      if (((MagickRealType) p->red < threshold) || 
     791          ((MagickRealType) p->green < threshold) || 
     792          ((MagickRealType) p->blue < threshold)) 
    779793        byte|=0x01; 
    780794      bit++; 
    781795      if (bit == 8) 
    782796        { 
    783           (void) SetRadonCell(source_cells,i++,y,bits[byte]); 
     797          (void) SetRadonCell(source_cells,--i,y,bits[byte]); 
    784798          bit=0; 
    785799          byte=0; 
     
    790804      { 
    791805        byte<<=(8-bit); 
    792         (void) SetRadonCell(source_cells,i++,y,bits[byte]); 
     806        (void) SetRadonCell(source_cells,--i,y,bits[byte]); 
    793807      } 
    794808  } 
     
    821835    bit=0; 
    822836    byte=0; 
    823     i=(long) (image->columns+7)/8; 
     837    i=0; 
    824838    for (x=0; x < (long) image->columns; x++) 
    825839    { 
    826840      byte<<=1; 
    827       if ((p->red < threshold) || (p->green < threshold) || 
    828           (p->blue < threshold)) 
     841      if (((MagickRealType) p->red < threshold) || 
     842          ((MagickRealType) p->green < threshold) || 
     843          ((MagickRealType) p->blue < threshold)) 
    829844        byte|=0x01; 
    830845      bit++; 
    831846      if (bit == 8) 
    832847        { 
    833           (void) SetRadonCell(source_cells,--i,y,bits[byte]); 
     848          (void) SetRadonCell(source_cells,i++,y,bits[byte]); 
    834849          bit=0; 
    835850          byte=0; 
     
    840855      { 
    841856        byte<<=(8-bit); 
    842         (void) SetRadonCell(source_cells,--i,y,bits[byte]); 
     857        (void) SetRadonCell(source_cells,i++,y,bits[byte]); 
    843858      } 
    844859  } 
     
    850865} 
    851866 
     867static void GetImageBackgroundColor(Image *image,const long offset, 
     868  ExceptionInfo *exception) 
     869{ 
     870  long 
     871    y; 
     872 
     873  MagickPixelPacket 
     874    background; 
     875 
     876  MagickRealType 
     877    count; 
     878 
     879  ViewInfo 
     880    *image_view; 
     881 
     882  /* 
     883    Compute average background color. 
     884  */ 
     885  if (offset <= 0) 
     886    return; 
     887  GetMagickPixelPacket(image,&background); 
     888  count=0.0; 
     889  image_view=AcquireCacheView(image); 
     890  for (y=0; y < (long) image->rows; y++) 
     891  { 
     892    register const PixelPacket 
     893      *p; 
     894 
     895    register long 
     896      x; 
     897 
     898    if ((y >= offset) && (y < ((long) image->rows-offset))) 
     899      continue; 
     900    p=AcquireCacheViewPixels(image_view,0,y,image->columns,1,exception); 
     901    if (p == (const PixelPacket *) NULL) 
     902      continue; 
     903    for (x=0; x < (long) image->columns; x++) 
     904    { 
     905      if ((x >= offset) && (x < ((long) image->columns-offset))) 
     906        continue; 
     907      background.red+=QuantumScale*p->red; 
     908      background.green+=QuantumScale*p->green; 
     909      background.blue+=QuantumScale*p->blue; 
     910      background.opacity+=QuantumScale*p->opacity; 
     911      count++; 
     912      p++; 
     913    } 
     914  } 
     915  image_view=DestroyCacheView(image_view); 
     916  image->background_color.red=RoundToQuantum((MagickRealType) QuantumRange* 
     917    background.red/count); 
     918  image->background_color.green=RoundToQuantum((MagickRealType) QuantumRange* 
     919    background.green/count); 
     920  image->background_color.blue=RoundToQuantum((MagickRealType) QuantumRange* 
     921    background.blue/count); 
     922  image->background_color.opacity=RoundToQuantum((MagickRealType) QuantumRange* 
     923    background.opacity/count); 
     924} 
     925 
    852926MagickExport Image *DeskewImage(const Image *image,const double threshold, 
    853927  ExceptionInfo *exception) 
    854928{ 
     929  const char 
     930    *artifact; 
     931 
    855932  double 
    856933    degrees, 
     
    858935 
    859936  Image 
    860     *deskew_image; 
     937    *clone_image, 
     938    *median_image, 
     939    *rotate_image; 
    861940 
    862941  long 
     
    865944  MagickBooleanType 
    866945    status; 
     946 
     947  RectangleInfo 
     948    geometry; 
    867949 
    868950  register long 
     
    904986    Deskew image. 
    905987  */ 
    906   degrees=RadiansToDegrees(atan((double) skew/width/8)); 
     988  degrees=RadiansToDegrees(-atan((double) skew/width/8)); 
    907989  if (image->debug != MagickFalse) 
    908990    (void) LogMagickEvent(TransformEvent,GetMagickModule(),"  Deskew angle: %g", 
    909991      degrees); 
    910   deskew_image=RotateImage(image,degrees,exception); 
    911   if (image->fuzz != 0.0) 
    912     { 
    913       Image 
    914         *image; 
    915  
    916       RectangleInfo 
    917         geometry; 
    918  
    919       /* 
    920         Trim image. 
    921       */ 
    922       image=ReduceNoiseImage(deskew_image,0.0,exception); 
    923       if (image != (Image *) NULL) 
    924         { 
    925           geometry=GetImageBoundingBox(image,exception); 
    926           image=DestroyImage(image); 
    927           image=CropImage(deskew_image,&geometry,exception); 
    928           if (image != (Image *) NULL) 
    929             { 
    930               deskew_image=DestroyImage(deskew_image); 
    931               deskew_image=image; 
    932             } 
    933         } 
    934     } 
    935   return(deskew_image); 
     992  artifact=GetImageArtifact(image,"deskew:auto-crop"); 
     993  if (artifact == (const char *) NULL) 
     994    return(RotateImage(image,degrees,exception)); 
     995  /* 
     996    Auto-crop image. 
     997  */ 
     998  clone_image=CloneImage(image,0,0,MagickTrue,exception); 
     999  if (clone_image == (Image *) NULL) 
     1000    return((Image *) NULL); 
     1001  GetImageBackgroundColor(clone_image,atol(artifact),exception); 
     1002  rotate_image=RotateImage(clone_image,degrees,exception); 
     1003  clone_image=DestroyImage(clone_image); 
     1004  if (rotate_image == (Image *) NULL) 
     1005    return((Image *) NULL); 
     1006  median_image=MedianFilterImage(rotate_image,0.0,exception); 
     1007  rotate_image=DestroyImage(rotate_image); 
     1008  if (median_image == (Image *) NULL) 
     1009    return((Image *) NULL); 
     1010  geometry=GetImageBoundingBox(median_image,exception); 
     1011  median_image=DestroyImage(median_image); 
     1012  if (image->debug != MagickFalse) 
     1013    (void) LogMagickEvent(TransformEvent,GetMagickModule(),"  Deskew geometry: " 
     1014      "%lux%lu%+ld%+ld",geometry.width,geometry.height,geometry.x,geometry.y); 
     1015  return(CropImage(image,&geometry,exception)); 
    9361016} 
    9371017  
     
    13331413  status=MagickTrue; 
    13341414  image_view=AcquireCacheViewThreadSet(image); 
    1335   #pragma omp parallel for 
     1415//  #pragma omp parallel for 
    13361416  for (y=0; y < (long) height; y++) 
    13371417  { 
     
    15271607  status=MagickTrue; 
    15281608  image_view=AcquireCacheViewThreadSet(image); 
    1529   #pragma omp parallel for 
     1609//  #pragma omp parallel for 
    15301610  for (x=0; x < (long) width; x++) 
    15311611  { 
  • ImageMagick/trunk/wand/mogrify.c

    r11577 r11613  
    870870            */ 
    871871            if (*option == '+') 
    872               threshold=QuantumRange/2.2; 
     872              threshold=40.0*QuantumRange/100.0; 
    873873            else 
    874874              threshold=StringToDouble(argv[i+1],QuantumRange);