]> granicus.if.org Git - imagemagick/blob - MagickCore/pixel-accessor.h
(no commit message)
[imagemagick] / MagickCore / pixel-accessor.h
1 /*
2   Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization
3   dedicated to making software imaging solutions freely available.
4
5   You may not use this file except in compliance with the License.
6   obtain a copy of the License at
7
8     http://www.imagemagick.org/script/license.php
9
10   Unless required by applicable law or agreed to in writing, software
11   distributed under the License is distributed on an "AS IS" BASIS,
12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   See the License for the specific language governing permissions and
14   limitations under the License.
15
16   MagickCore pixel accessor methods.
17 */
18 #ifndef _MAGICKCORE_PIXEL_ACCESSOR_H
19 #define _MAGICKCORE_PIXEL_ACCESSOR_H
20
21 #if defined(__cplusplus) || defined(c_plusplus)
22 extern "C" {
23 #endif
24
25 #include <math.h>
26 #include <MagickCore/cache-view.h>
27 #include <MagickCore/color.h>
28 #include <MagickCore/image.h>
29
30 #undef index
31
32 static inline Quantum GetPixelAlpha(const Image *restrict image,
33   const Quantum *restrict pixel)
34 {
35   if (image->channel_map[AlphaPixelChannel].traits == UndefinedPixelTrait)
36     return(OpaqueAlpha);
37   return(pixel[image->channel_map[AlphaPixelChannel].channel]);
38 }
39
40 static inline PixelTrait GetPixelAlphaTraits(const Image *restrict image)
41 {
42   return(image->channel_map[AlphaPixelChannel].traits);
43 }
44
45 static inline Quantum GetPixelBlack(const Image *restrict image,
46   const Quantum *restrict pixel)
47 {
48   if (image->channel_map[BlackPixelChannel].traits == UndefinedPixelTrait)
49     return(0);
50   return(pixel[image->channel_map[BlackPixelChannel].channel]);
51 }
52
53 static inline PixelTrait GetPixelBlackTraits(const Image *restrict image)
54 {
55   return(image->channel_map[BlackPixelChannel].traits);
56 }
57
58 static inline Quantum GetPixelBlue(const Image *restrict image,
59   const Quantum *restrict pixel)
60 {
61   return(pixel[image->channel_map[BluePixelChannel].channel]);
62 }
63
64 static inline PixelTrait GetPixelBlueTraits(const Image *restrict image)
65 {
66   return(image->channel_map[BluePixelChannel].traits);
67 }
68
69 static inline Quantum GetPixelCb(const Image *restrict image,
70   const Quantum *restrict pixel)
71 {
72   return(pixel[image->channel_map[CbPixelChannel].channel]);
73 }
74
75 static inline PixelTrait GetPixelCbTraits(const Image *restrict image)
76 {
77   return(image->channel_map[CbPixelChannel].traits);
78 }
79
80 static inline Quantum GetPixelChannel(const Image *restrict image,
81   const PixelChannel channel,const Quantum *restrict pixel)
82 {
83   if (image->channel_map[channel].traits == UndefinedPixelTrait)
84     return(0);
85   return(pixel[image->channel_map[channel].channel]);
86 }
87
88 static inline PixelChannel GetPixelChannelMapChannel(
89   const Image *restrict image,const PixelChannel channel)
90 {
91   return(image->channel_map[channel].channel);
92 }
93
94 static inline PixelTrait GetPixelChannelMapTraits(const Image *restrict image,
95   const PixelChannel channel)
96 {
97   return(image->channel_map[channel].traits);
98 }
99
100 static inline size_t GetPixelChannels(const Image *restrict image)
101 {
102   return(image->number_channels);
103 }
104
105 static inline Quantum GetPixelCr(const Image *restrict image,
106   const Quantum *restrict pixel)
107 {
108   return(pixel[image->channel_map[CrPixelChannel].channel]);
109 }
110
111 static inline PixelTrait GetPixelCrTraits(const Image *restrict image)
112 {
113   return(image->channel_map[CrPixelChannel].traits);
114 }
115
116 static inline Quantum GetPixelCyan(const Image *restrict image,
117   const Quantum *restrict pixel)
118 {
119   return(pixel[image->channel_map[CyanPixelChannel].channel]);
120 }
121
122 static inline PixelTrait GetPixelCyanTraits(const Image *restrict image)
123 {
124   return(image->channel_map[CyanPixelChannel].traits);
125 }
126
127 static inline Quantum GetPixelGray(const Image *restrict image,
128   const Quantum *restrict pixel)
129 {
130   return(pixel[image->channel_map[GrayPixelChannel].channel]);
131 }
132
133 static inline PixelTrait GetPixelGrayTraits(const Image *restrict image)
134 {
135   return(image->channel_map[GrayPixelChannel].traits);
136 }
137
138 static inline Quantum GetPixelGreen(const Image *restrict image,
139   const Quantum *restrict pixel)
140 {
141   return(pixel[image->channel_map[GreenPixelChannel].channel]);
142 }
143
144 static inline PixelTrait GetPixelGreenTraits(const Image *restrict image)
145 {
146   return(image->channel_map[GreenPixelChannel].traits);
147 }
148
149 static inline Quantum GetPixelIndex(const Image *restrict image,
150   const Quantum *restrict pixel)
151 {
152   if (image->channel_map[IndexPixelChannel].traits == UndefinedPixelTrait)
153     return(0);
154   return(pixel[image->channel_map[IndexPixelChannel].channel]);
155 }
156
157 static inline PixelTrait GetPixelIndexTraits(const Image *restrict image)
158 {
159   return(image->channel_map[IndexPixelChannel].traits);
160 }
161
162 static inline Quantum GetPixelInfoIntensity(
163   const PixelInfo *restrict pixel_info)
164 {
165 #if !defined(MAGICKCORE_HDRI_SUPPORT)
166   return((Quantum) (0.299*pixel_info->red+0.587*pixel_info->green+0.114*
167     pixel_info->blue+0.5));
168 #else
169   return((Quantum) (0.299*pixel_info->red+0.587*pixel_info->green+0.114*
170     pixel_info->blue));
171 #endif
172 }
173
174 static inline Quantum GetPixelInfoLuminance(
175   const PixelInfo *restrict pixel_info)
176 {
177   Quantum
178     luminance;
179
180 #if !defined(MAGICKCORE_HDRI_SUPPORT)
181   luminance=(Quantum) (0.21267*pixel_info->red+0.71516*pixel_info->green+
182     0.07217*pixel_info->blue+0.5);
183 #else
184   luminance=(Quantum) (0.21267*pixel_info->red+0.71516*pixel_info->green+
185     0.07217*pixel_info->blue);
186 #endif
187   return((Quantum) luminance);
188 }
189
190 static inline Quantum GetPixelMagenta(const Image *restrict image,
191   const Quantum *restrict pixel)
192 {
193   return(pixel[image->channel_map[MagentaPixelChannel].channel]);
194 }
195
196 static inline PixelTrait GetPixelMagentaTraits(const Image *restrict image)
197 {
198   return(image->channel_map[MagentaPixelChannel].traits);
199 }
200
201 static inline size_t GetPixelMetaChannels(const Image *restrict image)
202 {
203   return(image->number_meta_channels);
204 }
205
206 static inline size_t GetPixelMetacontentExtent(const Image *restrict image)
207 {
208   return(image->metacontent_extent);
209 }
210
211 static inline Quantum GetPixelRed(const Image *restrict image,
212   const Quantum *restrict pixel)
213 {
214   return(pixel[image->channel_map[RedPixelChannel].channel]);
215 }
216
217 static inline PixelTrait GetPixelRedTraits(const Image *restrict image)
218 {
219   return(image->channel_map[RedPixelChannel].traits);
220 }
221
222 static inline void GetPixelInfoPixel(const Image *restrict image,
223   const Quantum *restrict pixel,PixelInfo *restrict pixel_info)
224 {
225   pixel_info->red=(MagickRealType)
226     pixel[image->channel_map[RedPixelChannel].channel];
227   pixel_info->green=(MagickRealType)
228     pixel[image->channel_map[GreenPixelChannel].channel];
229   pixel_info->blue=(MagickRealType)
230     pixel[image->channel_map[BluePixelChannel].channel];
231   pixel_info->black=0;
232   if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
233     pixel_info->black=(MagickRealType)
234       pixel[image->channel_map[BlackPixelChannel].channel];
235   pixel_info->alpha=OpaqueAlpha;
236   if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
237     pixel_info->alpha=(MagickRealType)
238       pixel[image->channel_map[AlphaPixelChannel].channel];
239   pixel_info->index=0;
240   if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
241     pixel_info->index=(MagickRealType)
242       pixel[image->channel_map[IndexPixelChannel].channel];
243 }
244
245 static inline PixelTrait GetPixelTraits(const Image *restrict image,
246   const PixelChannel channel)
247 {
248   return(image->channel_map[channel].traits);
249 }
250
251 static inline Quantum GetPixelY(const Image *restrict image,
252   const Quantum *restrict pixel)
253 {
254   return(pixel[image->channel_map[YPixelChannel].channel]);
255 }
256
257 static inline PixelTrait GetPixelYTraits(const Image *restrict image)
258 {
259   return(image->channel_map[YPixelChannel].traits);
260 }
261
262 static inline Quantum GetPixelYellow(const Image *restrict image,
263   const Quantum *restrict pixel)
264 {
265   return(pixel[image->channel_map[YellowPixelChannel].channel]);
266 }
267
268 static inline PixelTrait GetPixelYellowTraits(const Image *restrict image)
269 {
270   return(image->channel_map[YellowPixelChannel].traits);
271 }
272
273 static inline MagickBooleanType IsPixelEquivalent(const Image *restrict image,
274   const Quantum *restrict p,const PixelInfo *restrict q)
275 {
276   if (((double) p[image->channel_map[RedPixelChannel].channel] == q->red) &&
277       ((double) p[image->channel_map[GreenPixelChannel].channel] == q->green) &&
278       ((double) p[image->channel_map[BluePixelChannel].channel] == q->blue))
279     return(MagickTrue);
280   return(MagickFalse);
281 }
282
283 static inline MagickBooleanType IsPixelGray(const Image *restrict image,
284   const Quantum *restrict pixel)
285 {
286 #if !defined(MAGICKCORE_HDRI_SUPPORT)
287   if ((pixel[image->channel_map[RedPixelChannel].channel] ==
288        pixel[image->channel_map[GreenPixelChannel].channel]) &&
289       (pixel[image->channel_map[GreenPixelChannel].channel] ==
290        pixel[image->channel_map[BluePixelChannel].channel]))
291     return(MagickTrue);
292 #else
293   {
294     double
295       alpha,
296       beta;
297
298     alpha=pixel[image->channel_map[RedPixelChannel].channel]-(double)
299       pixel[image->channel_map[GreenPixelChannel].channel];
300     beta=pixel[image->channel_map[GreenPixelChannel].channel]-(double)
301       pixel[image->channel_map[BluePixelChannel].channel];
302     if ((fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
303       return(MagickTrue);
304   }
305 #endif
306   return(MagickFalse);
307 }
308
309 static inline MagickBooleanType IsPixelInfoEquivalent(
310   const PixelInfo *restrict p,const PixelInfo *restrict q)
311 {
312   if ((p->matte != MagickFalse) && (q->matte == MagickFalse) &&
313       (fabs(p->alpha-OpaqueAlpha) > 0.5))
314     return(MagickFalse);
315   if ((q->matte != MagickFalse) && (p->matte == MagickFalse) &&
316       (fabs(q->alpha-OpaqueAlpha)) > 0.5)
317     return(MagickFalse);
318   if ((p->matte != MagickFalse) && (q->matte != MagickFalse))
319     {
320       if (fabs(p->alpha-q->alpha) > 0.5)
321         return(MagickFalse);
322       if (fabs(p->alpha-TransparentAlpha) <= 0.5)
323         return(MagickTrue);
324     }
325   if (fabs(p->red-q->red) > 0.5)
326     return(MagickFalse);
327   if (fabs(p->green-q->green) > 0.5)
328     return(MagickFalse);
329   if (fabs(p->blue-q->blue) > 0.5)
330     return(MagickFalse);
331   if ((p->colorspace == CMYKColorspace) && (fabs(p->black-q->black) > 0.5))
332     return(MagickFalse);
333   return(MagickTrue);
334 }
335
336 static inline MagickBooleanType IsPixelMonochrome(const Image *restrict image,
337   const Quantum *restrict pixel)
338 {
339 #if !defined(MAGICKCORE_HDRI_SUPPORT)
340   if (((pixel[image->channel_map[RedPixelChannel].channel] == 0) ||
341       (pixel[image->channel_map[RedPixelChannel].channel] == (Quantum) QuantumRange)) &&
342       (pixel[image->channel_map[RedPixelChannel].channel] ==
343        pixel[image->channel_map[GreenPixelChannel].channel]) &&
344       (pixel[image->channel_map[GreenPixelChannel].channel] ==
345        pixel[image->channel_map[BluePixelChannel].channel]))
346     return(MagickTrue);
347 #else
348   {
349     double
350       alpha,
351       beta;
352
353     alpha=pixel[image->channel_map[RedPixelChannel].channel]-(double)
354       pixel[image->channel_map[GreenPixelChannel].channel];
355     beta=pixel[image->channel_map[GreenPixelChannel].channel]-(double)
356       pixel[image->channel_map[BluePixelChannel].channel];
357     if (((fabs(pixel[image->channel_map[RedPixelChannel].channel]) <=
358             MagickEpsilon) ||
359          (fabs(pixel[image->channel_map[RedPixelChannel].channel]-
360             QuantumRange) <= MagickEpsilon)) &&
361         (fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
362       return(MagickTrue);
363     }
364 #endif
365   return(MagickFalse);
366 }
367
368 static inline MagickBooleanType IsPixelInfoGray(
369   const PixelInfo *restrict pixel_info)
370 {
371 #if !defined(MAGICKCORE_HDRI_SUPPORT)
372   if ((pixel_info->red == pixel_info->green) &&
373       (pixel_info->green == pixel_info->blue))
374     return(MagickTrue);
375 #else
376   {
377     double
378       alpha,
379       beta;
380
381     alpha=pixel_info->red-(double) pixel_info->green;
382     beta=pixel_info->green-(double) pixel_info->blue;
383     if ((fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
384       return(MagickTrue);
385   }
386 #endif
387   return(MagickFalse);
388 }
389
390 static inline MagickBooleanType IsPixelInfoMonochrome(
391   const PixelInfo *restrict pixel_info)
392 {
393 #if !defined(MAGICKCORE_HDRI_SUPPORT)
394   if (((pixel_info->red == 0) || (pixel_info->red == (Quantum) QuantumRange)) &&
395       (pixel_info->red == pixel_info->green) &&
396       (pixel_info->green == pixel_info->blue))
397     return(MagickTrue);
398 #else
399   {
400     double
401       alpha,
402       beta;
403
404     alpha=pixel_info->red-(double) pixel_info->green;
405     beta=pixel_info->green-(double) pixel_info->blue;
406     if (((fabs(pixel_info->red) <= MagickEpsilon) ||
407          (fabs(pixel_info->red-QuantumRange) <= MagickEpsilon)) &&
408         (fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
409       return(MagickTrue);
410     }
411 #endif
412   return(MagickFalse);
413 }
414
415 static inline void SetPixelAlpha(const Image *restrict image,
416   const Quantum alpha,Quantum *restrict pixel)
417 {
418   if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
419     pixel[image->channel_map[AlphaPixelChannel].channel]=alpha;
420 }
421
422 static inline void SetPixelAlphaTraits(Image *image,const PixelTrait traits)
423 {
424   image->channel_map[AlphaPixelChannel].traits=traits;
425 }
426
427 static inline void SetPixelBlack(const Image *restrict image,
428   const Quantum black,Quantum *restrict pixel)
429 {
430   if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
431     pixel[image->channel_map[BlackPixelChannel].channel]=black;
432 }
433
434 static inline void SetPixelBlackTraits(Image *image,const PixelTrait traits)
435 {
436   image->channel_map[BlackPixelChannel].traits=traits;
437 }
438
439 static inline void SetPixelBlue(const Image *restrict image,const Quantum blue,
440   Quantum *restrict pixel)
441 {
442   pixel[image->channel_map[BluePixelChannel].channel]=blue;
443 }
444
445 static inline void SetPixelBlueTraits(Image *image,const PixelTrait traits)
446 {
447   image->channel_map[BluePixelChannel].traits=traits;
448 }
449
450 static inline void SetPixelCb(const Image *restrict image,const Quantum cb,
451   Quantum *restrict pixel)
452 {
453   pixel[image->channel_map[CbPixelChannel].channel]=cb;
454 }
455
456 static inline void SetPixelCbTraits(Image *image,const PixelTrait traits)
457 {
458   image->channel_map[CbPixelChannel].traits=traits;
459 }
460
461 static inline void SetPixelChannel(const Image *restrict image,
462   const PixelChannel channel,const Quantum quantum,Quantum *restrict pixel)
463 {
464   if (image->channel_map[channel].traits != UndefinedPixelTrait)
465     pixel[image->channel_map[channel].channel]=quantum;
466 }
467
468 static inline void SetPixelChannelMapChannel(const Image *restrict image,
469   const PixelChannel channel,const PixelChannel channels)
470 {
471   image->channel_map[channel].channel=channels;
472 }
473
474 static inline void SetPixelChannels(Image *image,const size_t number_channels)
475 {
476   image->number_channels=number_channels;
477 }
478
479 static inline void SetPixelChannelTraits(Image *image,
480   const PixelChannel channel,const PixelTrait traits)
481 {
482   image->channel_map[channel].traits=traits;
483 }
484
485 static inline void SetPixelChannelMapTraits(Image *image,
486   const PixelChannel channel,const PixelTrait traits)
487 {
488   image->channel_map[channel].traits=traits;
489 }
490
491 static inline void SetPixelCr(const Image *restrict image,const Quantum cr,
492   Quantum *restrict pixel)
493 {
494   pixel[image->channel_map[CrPixelChannel].channel]=cr;
495 }
496
497 static inline void SetPixelCrTraits(Image *image,const PixelTrait traits)
498 {
499   image->channel_map[CrPixelChannel].traits=traits;
500 }
501
502 static inline void SetPixelCyan(const Image *restrict image,const Quantum cyan,
503   Quantum *restrict pixel)
504 {
505   pixel[image->channel_map[CyanPixelChannel].channel]=cyan;
506 }
507
508 static inline void SetPixelGray(const Image *restrict image,const Quantum gray,
509   Quantum *restrict pixel)
510 {
511   pixel[image->channel_map[GrayPixelChannel].channel]=gray;
512 }
513
514 static inline void SetPixelGrayTraits(Image *image,const PixelTrait traits)
515 {
516   image->channel_map[GrayPixelChannel].traits=traits;
517 }
518
519 static inline void SetPixelGreen(const Image *restrict image,
520   const Quantum green,Quantum *restrict pixel)
521 {
522   pixel[image->channel_map[GreenPixelChannel].channel]=green;
523 }
524
525 static inline void SetPixelGreenTraits(Image *image,const PixelTrait traits)
526 {
527   image->channel_map[GreenPixelChannel].traits=traits;
528 }
529
530 static inline void SetPixelIndex(const Image *restrict image,
531   const Quantum index,Quantum *restrict pixel)
532 {
533   if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
534     pixel[image->channel_map[IndexPixelChannel].channel]=index;
535 }
536
537 static inline void SetPixelIndexTraits(Image *image,const PixelTrait traits)
538 {
539   image->channel_map[IndexPixelChannel].traits=traits;
540 }
541
542 static inline void SetPixelInfo(const Image *restrict image,
543   const PixelInfo *restrict p,PixelInfo *restrict q)
544 {
545   q->red=p->red;
546   q->green=p->green;
547   q->blue=p->blue;
548   q->black=0;
549   if (image->channel_map[BlackPixelChannel].traits != UndefinedPixelTrait)
550     q->black=p->black;
551   q->alpha=OpaqueAlpha;
552   if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
553     q->alpha=p->alpha;
554   q->index=0;
555   if (image->channel_map[IndexPixelChannel].traits != UndefinedPixelTrait)
556     q->index=p->index;
557 }
558
559 static inline void SetPixelInfoPixel(const Image *restrict image,
560   const PixelInfo *restrict pixel_info,Quantum *restrict pixel)
561 {
562   pixel[image->channel_map[RedPixelChannel].channel]=
563     ClampToQuantum(pixel_info->red);
564   pixel[image->channel_map[GreenPixelChannel].channel]=
565     ClampToQuantum(pixel_info->green);
566   pixel[image->channel_map[BluePixelChannel].channel]=
567     ClampToQuantum(pixel_info->blue);
568   if (image->colorspace == CMYKColorspace)
569     pixel[image->channel_map[BlackPixelChannel].channel]=
570       ClampToQuantum(pixel_info->black);
571   if (image->channel_map[AlphaPixelChannel].traits != UndefinedPixelTrait)
572     pixel[image->channel_map[AlphaPixelChannel].channel]=
573       ClampToQuantum(pixel_info->alpha);
574 }
575
576 static inline void SetPixelMagenta(const Image *restrict image,
577   const Quantum magenta,Quantum *restrict pixel)
578 {
579   pixel[image->channel_map[MagentaPixelChannel].channel]=magenta;
580 }
581
582 static inline void SetPixelMagentaTraits(Image *image,const PixelTrait traits)
583 {
584   image->channel_map[MagentaPixelChannel].traits=traits;
585 }
586
587 static inline void SetPixelMetaChannels(Image *image,
588   const size_t number_meta_channels)
589 {
590   image->number_meta_channels=number_meta_channels;
591 }
592
593 static inline void SetPixelMetacontentExtent(Image *image,const size_t extent)
594 {
595   image->metacontent_extent=extent;
596 }
597
598 static inline void SetPixelRed(const Image *restrict image,const Quantum red,
599   Quantum *restrict pixel)
600 {
601   pixel[image->channel_map[RedPixelChannel].channel]=red;
602 }
603
604 static inline void SetPixelRedTraits(Image *image,const PixelTrait traits)
605 {
606   image->channel_map[RedPixelChannel].traits=traits;
607 }
608
609 static inline void SetPixelYellow(const Image *restrict image,
610   const Quantum yellow,Quantum *restrict pixel)
611 {
612   pixel[image->channel_map[YellowPixelChannel].channel]=yellow;
613 }
614
615 static inline void SetPixelYellowTraits(Image *image,const PixelTrait traits)
616 {
617   image->channel_map[YellowPixelChannel].traits=traits;
618 }
619
620 static inline void SetPixelY(const Image *restrict image,const Quantum y,
621   Quantum *restrict pixel)
622 {
623   pixel[image->channel_map[YPixelChannel].channel]=y;
624 }
625
626 static inline void SetPixelYTraits(Image *image,const PixelTrait traits)
627 {
628   image->channel_map[YPixelChannel].traits=traits;
629 }
630
631 static inline Quantum GetPixelIntensity(const Image *restrict image,
632   const Quantum *restrict pixel)
633 {
634 #if !defined(MAGICKCORE_HDRI_SUPPORT)
635   if ((pixel[image->channel_map[RedPixelChannel].channel] ==
636        pixel[image->channel_map[GreenPixelChannel].channel]) &&
637       (pixel[image->channel_map[GreenPixelChannel].channel] ==
638        pixel[image->channel_map[BluePixelChannel].channel]))
639     return(pixel[image->channel_map[RedPixelChannel].channel]);
640   return((Quantum) (0.299*pixel[image->channel_map[RedPixelChannel].channel]+
641     0.587*pixel[image->channel_map[GreenPixelChannel].channel]+0.114*
642     pixel[image->channel_map[BluePixelChannel].channel]+0.5));
643 #else
644   {
645     double
646       alpha,
647       beta;
648
649     alpha=pixel[image->channel_map[RedPixelChannel].channel]-(double)
650       pixel[image->channel_map[GreenPixelChannel].channel];
651     beta=pixel[image->channel_map[GreenPixelChannel].channel]-(double)
652       pixel[image->channel_map[BluePixelChannel].channel];
653     if ((fabs(alpha) <= MagickEpsilon) && (fabs(beta) <= MagickEpsilon))
654       return(pixel[image->channel_map[RedPixelChannel].channel]);
655     return((Quantum) (0.299*pixel[image->channel_map[RedPixelChannel].channel]+
656       0.587*pixel[image->channel_map[GreenPixelChannel].channel]+0.114*
657       pixel[image->channel_map[BluePixelChannel].channel]));
658   }
659 #endif
660 }
661
662 static inline Quantum GetPixelLuminance(const Image *restrict image,
663   const Quantum *restrict pixel)
664 {
665 #if !defined(MAGICKCORE_HDRI_SUPPORT)
666   return((Quantum) (0.21267*pixel[image->channel_map[RedPixelChannel].channel]+
667     0.71516*pixel[image->channel_map[GreenPixelChannel].channel]+0.07217*
668     pixel[image->channel_map[BluePixelChannel].channel]+0.5));
669 #else
670   return((Quantum) (0.21267*pixel[image->channel_map[RedPixelChannel].channel]+
671     0.71516*pixel[image->channel_map[GreenPixelChannel].channel]+0.07217*
672     pixel[image->channel_map[BluePixelChannel].channel]));
673 #endif
674 }
675
676 #if defined(__cplusplus) || defined(c_plusplus)
677 }
678 #endif
679
680 #endif