Ask Your Question

pablobhz's profile - activity

2020-06-27 15:21:37 -0600 received badge  Popular Question (source)
2019-02-06 10:52:26 -0600 asked a question RAW CMYK Data in OpenCV

RAW CMYK Data in OpenCV Hello Everyone. I"m aware that OpenCV cannot handle RAW image data , so i followed this guide to

2017-04-12 14:46:37 -0600 asked a question convert white pixels to transparent

I'm trying to convert the white pixels on a image to transparent, ussing the following code:

// load as color image BGR cv::Mat input = cv::imread("C:/StackOverflow/Input/transparentWhite.png");

cv::Mat input_bgra;
cv::cvtColor(input, input_bgra, CV_BGR2BGRA);

// find all white pixel and set alpha value to zero:
for (int y = 0; y < input_bgra.rows; ++y)
for (int x = 0; x < input_bgra.cols; ++x)
{
    cv::Vec4b & pixel = input_bgra.at<cv::Vec4b>(y, x);
    // if pixel is white
    if (pixel[0] == 255 && pixel[1] == 255 && pixel[2] == 255)
    {
        // set alpha to zero:
        pixel[3] = 0;
    }
}

// save as .png file (which supports alpha channels/transparency)
cv::imwrite("C:/inputfolder/Output/transparentWhite.png", input_bgra);

However, when i open the image, white pixels are still white (not transparent).

WHat am i doing wrong ? Thx

2017-02-20 08:44:43 -0600 commented question Emgu copy smaller image into bigger image ROI

Yeah. I am sorry, i read your comment in my previous post but it was already posted, couldn't cancel. Sorry for the trouble :)

2017-02-20 06:49:31 -0600 asked a question Emgu copy smaller image into bigger image ROI

I've got two images. 1 - 10596w x 7370h 2 - 7085w x 9920h. Both white background.

What i'm trying to do, is copy image 2 into the center of image 1. However, when i try to copy, i receive the following exception:OpenCv: src.Channels() == dst.Channels() == dst.Channels() && src.Depth == dst.Depth();

Both images are initialised already (imageResult and newImage).

Here's what i am trying to do:

Bgr whiteBgr = new Bgr(255, 255, 255);
            Image<Bgr, Byte> imageResult = new Image<Bgr, byte>(zAreaWidth, zAreaHeight,whiteBgr);
imageResult.ROI = new Rectangle(topBorder ,rightBorder, newImage.Width, newImage.Height);
                        newImage.CopyTo(imageResult);
                        imageResult.Save(@"C:\DI_PLOT\imageresult.png");

No variable is negative or out of range. rightBorder = image1.Width - image2.Width topBorder = image1.Height - image2.Height;

2017-02-17 06:33:57 -0600 asked a question Rotate image correctly

I'm using Emgu to rotate a very large image (7085w x 9920h)

However, after rotating it , he seems to "Invert" width and height. On the rotated image (using Windows Image Viewer), after rotating it 90 degrees the image has 9920w x 7085h.

With Emgu, after rotating and saving it (testing), the image has 7085w x 9920h.

What can be happening in that case ? I'm passing the correct parameters, but i've got no idea why this behaviour is happening.

newImage = newImage.Rotate(90, new Bgr(0, 0, 0));

Thanks in advance