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