Ask Your Question

Evoxz's profile - activity

2015-02-07 15:43:47 -0600 asked a question Vary pixel BGR color to define some pixel ranges

Hi :) I've got a problem to vary the pixel color of an image... I begin with a white image of 4096*4096px. I want to vary the color of each pixel to be able to clearly see the color change and be able to define pixel ranges (for example : from 'OneValueOfColor' to 'AnotherVAlueOfColor', I define that it's the color "brown"). Here is my code. When I execute, I obtain a strange image... (PlagesIncrement.bmp is the white image created with paint) The cout '|' and '\t' just allowed me to do a charging bar. Thank you in advance :)

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;
unsigned int B = 0, G = 0, R = 0;
int savedPourcentage = 0, pourcentage;
bool hbreak= false;
int main ()
{
    cout << "1%" << "\t\t\t\t\t\t\t" << "100%" << '\n';
    Mat image;
    image = imread("C:\\Users\\Xavier\\Desktop\\Sat-Turn\\Images OpenCV\\PlagesIncrement.bmp", CV_LOAD_IMAGE_COLOR ); // Read the file
    if(! image.data ) 
    {
        cout << "Could not open or find the image" << std::endl ;
        return -1;
    }
    Vec3b couleur = image.at<Vec3b>(0,0);
    for (int y = 0; y < 4096; y++) {
        for (int x = 0; x< 4096; x++){
            image.at<Vec3b>(x,y) [0] = (uchar) B;
            image.at<Vec3b>(x,y) [1] = (uchar) G;
            image.at<Vec3b>(x,y) [2] = (uchar) R; 
            R++;
            if (R > 255) {
                R = 0;
                G++;
            }
            if (G > 255) {
            G = 0;
            B++;
            }
            //image.at<Vec3b> (x,y) = couleur;
            if (B > 255) {break; hbreak = true;}

        }
        if (hbreak) break;
        pourcentage = (int) ((((double) y/4096))*100);
        if (savedPourcentage < pourcentage-4) {
            cout << '|'<< '|'<<'|';
            savedPourcentage = pourcentage;
        }
    }
    cout << endl;
    namedWindow( "Display window", WINDOW_AUTOSIZE ); 
    imshow( "Display window", image ); 
    waitKey(0); 
    return 0;
}
2015-02-07 02:20:51 -0600 received badge  Supporter (source)
2015-02-07 02:20:49 -0600 received badge  Scholar (source)
2015-02-07 02:18:25 -0600 commented answer BGR pixel transformations

Thanks a lot! :) And how can I do to change these values?

2015-02-07 00:24:51 -0600 asked a question BGR pixel transformations

Hi :) I'm searching for a function wich is able to get the BGR data of any pixel (with the X/Y coordinates of this pixel) and change it. Do you know something about a function like that? I program in C++.

Best regards, Evoxz

2015-02-06 01:14:16 -0600 commented question Problem : Couldn't find or open the image

I've already tried it... with CMD i ran "Sat-Turn OpenCV.exe 7.jpg"... It didn't work. I've also tried with the absolute path but it doesn't work too. Have you got another idea?

2015-02-05 15:41:34 -0600 received badge  Editor (source)
2015-02-05 14:49:49 -0600 asked a question Problem : Couldn't find or open the image

Hi all :) To begin with, I wanted to say you that i'm not a native speaker and I'm only 16, so please be tolerant with my English :p Moreover, I begin with OpenCV by myself, so I know almost nothing about it... HEre is my question : In fact, I was in one of the first tutorial (http://docs.opencv.org/doc/tutorials/...) and I tried to display an image. But I can't do it... I've tried to execute the exe file with CMD, with "release interface" in Visual Studio ultimate 2012 with arguments,... (I've also tried to put the image file (I've tried with bmp and jpg formats) into C:, my project's folder, the release's folder where I can find the .exe,...) Whatever I do, the image doesn't appear and I can just read "Could not open or find the image" (the text who appear when !image.data is true) Have one of you the answer? Best regards, Evoxz

PS : The code I use can be found on the tutorial I linked, I haven't changed anything

NB : I use OpenCV 2.4.10, the latest final version