gamma=log(mean*QuantumScale)/log_mean;
status&=LevelImage(image,0.0,(double) QuantumRange,gamma,exception);
(void) SetImageChannelMask(image,channel_mask);
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
break;
}
return(status != 0 ? MagickTrue : MagickFalse);
register ssize_t
x;
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
register ssize_t
x;
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
register ssize_t
x;
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
CacheView
*image_view;
- MagickBooleanType
- status;
-
- MagickOffsetType
- progress;
-
double
*black,
*histogram,
*stretch_map,
*white;
+ MagickBooleanType
+ status;
+
+ MagickOffsetType
+ progress;
+
register ssize_t
i;
/*
Form histogram.
*/
- if( IfMagickTrue(IsImageGray(image,exception)) )
+ if (IsImageGray(image,exception) != MagickFalse)
(void) SetImageColorspace(image,GRAYColorspace,exception);
status=MagickTrue;
(void) ResetMagickMemory(histogram,0,(MaxMap+1)*number_channels*
register ssize_t
x;
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
for (j=0; j <= (ssize_t) MaxMap; j++)
{
+ double
+ gamma;
+
+ gamma=PerceptibleReciprocal(white[i]-black[i]);
if (j < (ssize_t) black[i])
stretch_map[number_channels*j+i]=0.0;
else
if (j > (ssize_t) white[i])
stretch_map[number_channels*j+i]=(double) QuantumRange;
else
- if (black[i] != white[i])
- stretch_map[number_channels*j+i]=(double) ScaleMapToQuantum(
- (double) (MaxMap*(j-black[i])/(white[i]-black[i])));
+ stretch_map[number_channels*j+i]=(double) ScaleMapToQuantum(
+ (double) (MaxMap*gamma*(j-black[i])));
}
}
if (image->storage_class == PseudoClass)
if ((GetPixelRedTraits(image) & UpdatePixelTrait) != 0)
{
i=GetPixelChannelChannel(image,RedPixelChannel);
- if (black[i] != white[i])
- image->colormap[j].red=stretch_map[number_channels*
- ScaleQuantumToMap(ClampToQuantum(image->colormap[j].red))+i];
+ image->colormap[j].red=stretch_map[number_channels*
+ ScaleQuantumToMap(ClampToQuantum(image->colormap[j].red))+i];
}
if ((GetPixelGreenTraits(image) & UpdatePixelTrait) != 0)
{
i=GetPixelChannelChannel(image,GreenPixelChannel);
- if (black[i] != white[i])
- image->colormap[j].green=stretch_map[number_channels*
- ScaleQuantumToMap(ClampToQuantum(image->colormap[j].green))+i];
+ image->colormap[j].green=stretch_map[number_channels*
+ ScaleQuantumToMap(ClampToQuantum(image->colormap[j].green))+i];
}
if ((GetPixelBlueTraits(image) & UpdatePixelTrait) != 0)
{
i=GetPixelChannelChannel(image,BluePixelChannel);
- if (black[i] != white[i])
- image->colormap[j].blue=stretch_map[number_channels*
- ScaleQuantumToMap(ClampToQuantum(image->colormap[j].blue))+i];
+ image->colormap[j].blue=stretch_map[number_channels*
+ ScaleQuantumToMap(ClampToQuantum(image->colormap[j].blue))+i];
}
if ((GetPixelAlphaTraits(image) & UpdatePixelTrait) != 0)
{
i=GetPixelChannelChannel(image,AlphaPixelChannel);
- if (black[i] != white[i])
- image->colormap[j].alpha=stretch_map[number_channels*
- ScaleQuantumToMap(ClampToQuantum(image->colormap[j].alpha))+i];
+ image->colormap[j].alpha=stretch_map[number_channels*
+ ScaleQuantumToMap(ClampToQuantum(image->colormap[j].alpha))+i];
}
}
}
register ssize_t
x;
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
{
PixelChannel channel=GetPixelChannelChannel(image,i);
PixelTrait traits=GetPixelChannelTraits(image,channel);
- if (((traits & UpdatePixelTrait) == 0) || (black[i] == white[i]))
+ if ((traits & UpdatePixelTrait) == 0)
continue;
- q[i]=ClampToQuantum(stretch_map[number_channels*
- ScaleQuantumToMap(q[i])+i]);
+ q[i]=ClampToQuantum(stretch_map[number_channels*ScaleQuantumToMap(q[i])+
+ channel]);
}
q+=number_channels;
}
- if( IfMagickFalse(SyncCacheViewAuthenticPixels(image_view,exception)) )
+ if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
status=MagickFalse;
if (image->progress_monitor != (MagickProgressMonitor) NULL)
{
#endif
proceed=SetImageProgress(image,ContrastStretchImageTag,progress++,
image->rows);
- if( IfMagickFalse(proceed) )
+ if (proceed == MagickFalse)
status=MagickFalse;
}
}
ssize_t
center;
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,-2,y-2,image->columns+4,5,exception);
q=QueueCacheViewAuthenticPixels(enhance_view,0,y,enhance_image->columns,1,
}
enhance_view=DestroyCacheView(enhance_view);
image_view=DestroyCacheView(image_view);
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
enhance_image=DestroyImage(enhance_image);
return(enhance_image);
}
register ssize_t
x;
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
register ssize_t
x;
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
register ssize_t
x;
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
register ssize_t
x;
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
register ssize_t
x;
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
register ssize_t
x;
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
register ssize_t
x;
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
register ssize_t
x;
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
register ssize_t
x;
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
exception);
register ssize_t
x;
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
register ssize_t
x;
- if( IfMagickFalse(status) )
+ if (status == MagickFalse)
continue;
q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)