- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

I'm a little confused. The function RGBToGray will work for BGR format too? Or I have to do the conversion before? Thank you very much.

Link Copied

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

If there's a version with planar input, then yes you could and just swap the R and B planes

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

**full names**for IPP functions when you're describing a problem or asking a question. Thanks in advance.

**Note:**Actually this is a discussion about a set of IPP functions

**ippiRGBToGray_xx_xxxxx**. >>... So, here worked fine with BGR format too... A very famous equation

**Y**= 0.299 *

**R**+ 0.587 *

**G**+ 0.114 *

**B**is used to do this conversion RGB to Gray. However, you need to verify that it doesn't do something like:

**Y**= 0.299 *

**B**+ 0.587 *

**G**+ 0.114 *

**R**I'm Not sure that it does not.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

If Sergey are right and you see wrong coefficients for B & R - use another function, please:

/* /////////////////////////////////////////////////////////////////////////////

// Name: ippiColorToGray

// Purpose: Converts an RGB image to gray scale (custom coefficients)

// Parameters:

// pSrc Pointer to the source image , points to point(0,0)

// pDst Pointer to the destination image , points to point(0,0)

// roiSize Size of the ROI in pixels. Since the function performs point

// operations (without a border), the ROI may be the whole image.

// srcStep Step in bytes through the source image to jump on the next line

// dstStep Step in bytes through the destination image to jump on the next line

// coeffs[3] User-defined vector of coefficients.

// The sum of the coefficients should be less than or equal to 1

// Returns:

// ippStsNullPtrErr pSrc == NULL, or pDst == NULL

// ippStsSizeErr roiSize has a field with zero or negative value

// ippStsNoErr No errors

//

// The following equation is used to convert an RGB image to gray scale:

//

// Y = coeffs[0] * R + coeffs[1] * G + coeffs[2] * B;

//

//

*/

just swap coefficients from the formula above.

Regards, Igor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

**Case 1**Y = 0.299 * R + 0.587 * G + 0.114 * B Y = 0.299 * 64 + 0.587 * 128 + 0.114 * 192 =

**116.16**

**Case 2**Y = 0.299 * B + 0.587 * G + 0.114 * R Y = 0.299 * 192 + 0.587 * 128 + 0.114 * 64 =

**139.84**Intensity of a grey image is Not the same, as you can see. In some applications, like X-Ray imaging or MRI, incorect conversions are Not allowed.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page