Ask Your Question

BartBB's profile - activity

2018-04-21 23:31:17 -0600 received badge  Notable Question (source)
2017-07-28 10:20:16 -0600 received badge  Popular Question (source)
2015-12-20 06:48:25 -0600 asked a question Looping through pixels in an image and comparing them to previous/next ones.

The title says it all.

What I am trying to do is loop through all pixels in an image (successfully so far) and compare one pixel's color to the previous and next one. (Could be next column or next row, doesn't really matter)

Oh ye, and eventually, modify the previous/next pixel.

Now, the idea sounds pretty simple, but since I'm new to OpenCV I must be doing something wrong since I keep getting errors. (More like.. when I run the project it just stops unexpectedly)

My code:

for (int row = 0; row < image.rows; row++)
{
    for (int col = 0; col < image.cols; col++)
    {
        Vec3b pColor = image.at<Vec3b>(Point(col, row));

        if (pColor[0] > 240 && pColor[1] > 240 && pColor[2] > 240)
        {
            if (row > 0 && col > 0 && row < (image.rows - 1) && col < (image.cols - 1))
            {
                Vec3b nColor = image.at<Vec3b>(Point(col - 1, row));

                if (nColor[0] < 240 && nColor[1] < 240 && nColor[2] < 240)
                {
                    image.at<Vec3b>(col - 1, row)[0] = 1;
                    image.at<Vec3b>(col - 1, row)[1] = 1;
                    image.at<Vec3b>(col - 1, row)[2] = 255;
                }

Of course, there is more, but this is the problematic area. I've found the exact line which causes the sudden stop and it is:

Vec3b nColor = image.at<vec3b>(Point(col - 1, row));

If I remove the "-1" from the line, the code runs, but of course, not as I want it to. Perhaps I am missing some knowledge of how OpenCV works. I mean, this should work by my understanding, I make sure the current row and column is more than 0 which means I have enough place to go back by one in each of them, so I see no problem.

Any help is greatly appreciated.

Thank you in advance.

2015-12-20 01:56:03 -0600 received badge  Enthusiast
2015-12-19 13:17:03 -0600 commented answer Loading image and getting each pixel's color (C++)

Thanks. Guess I should've just looked it up before asking.

2015-12-19 13:16:42 -0600 received badge  Scholar (source)
2015-12-19 12:32:29 -0600 asked a question Loading image and getting each pixel's color (C++)

Hello there,

I have just finished configuring OpenCV with Visual Studio 2013, so I don't have much knowledge of it. Hence, I am asking such a basic thing.

I need to load an image and loop through every pixel and check its color. That's pretty much it.

Thank you in advance.

2015-12-19 08:36:04 -0600 commented question Getting build/source files?

Problem is.. I just downloaded the latest version of it. I should probably convince my teacher to allow me to use something different than CodeBlocks. Maybe I didn't install numpy properly? I mean, I just double clicked ez_setup.py. Should that not be enough?

2015-12-19 07:34:50 -0600 commented question Getting build/source files?

I think I might understand what you mean. Do you mean to build my codeblocks project? The one I intend to make with the opencv functions or did I get you wrong? If that is what you mean, I still have not connected opencv to codeblocks, because the folders in opencv -> build -> x86 -> mingw are empty. In order to connect opencv to codeblocks I need to link it with the folder lib which is supposed to contain a lot of different files (according to the guides) but for me they're empty. I did notice a problem with CMake, perhaps if I post the output you could help?

Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named numpy.distutils Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named 'numpy'

2015-12-19 03:23:22 -0600 commented question Getting build/source files?

Thing is, I've not yet touched a single command line, so I have no idea where to write that. According to the guides I've followed so far: One guide simply installed OpenCV and CodeBlocks and already had the mingw folder in build->x86 and everything was in place. Another guide says to use CMake but whenever I do as the guide says, my lib and bin folders end up empty while the guide has their folders full of files. I just don't see what I'm doing wrong. If you could please explain yourself better I will really appreciate it.

2015-12-19 02:08:08 -0600 commented question Getting build/source files?

What do you mean by that? I don't quite understand how that is done. I still haven't been able to configure OpenCV with CodeBlocks.

2015-12-18 13:18:42 -0600 commented question Getting build/source files?

Fixed those specific errors yet my lib and bin folders in the destination of CMake are still empty. Any clue?

2015-12-16 12:19:27 -0600 commented question Getting build/source files?

I have installed python using the python windows executable installer but when I ran CMake it gave me the same errors. I must be doing something wrong. I'm going to search online, but I'll still leave this here, perhaps I won't find a solution (which I highly doubt) and you know it.

Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "2.7") Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "2.6") Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "3.4") Could NOT find PythonInterp (missing: PYTHON_EXECUTABLE) (Required is at least version "3.2")

2015-12-16 07:45:14 -0600 commented question Getting build/source files?

I have ran it once again, even before you asked me to. I don't know what changed but this time everything was successful except for a few things which require python (which I am just about to configure and then try again) if it doesn't work I will be sure to let you know.

2015-12-16 05:28:37 -0600 received badge  Editor (source)
2015-12-16 03:59:36 -0600 commented question Getting build/source files?

Alright, so.. I've downloaded what you linked the master(3.0) one and used CMake. It all went smoothly until the moment it nearly finished generating the files or whatever CMake does. Then I got loads or red messages. Warnings to be precise. Thought I could ignore it and give it a shot, went to the destination folder and went inside then to the bin folder inside of it and it was empty. I'm unsure about whether that's alright or not (Seems not good to me) and I'm gonna follow the first guide from this point and see if it works.

I hope it works, but I honestly quite doubt it.

EDIT: Ye.. something still doesn't work. Most if not all folders in the mingw folder do not have any files in them.

2015-12-16 00:56:45 -0600 asked a question Getting build/source files?

I'm following a guide of how to connect OpenCV to CodeBlocks and in one of the steps, I am supposed to use CMake to build the binary files, or something like that. (New to all this tbh, but I need this badly so I'm not giving up)

While following this file something didn't fit to the guide, so I asked online and they referred me to another guide, which tells me to use TortoiseGit and get the source files, or build files, idk. But when I use the provided link, TortoiseGit crashes.

So.. my question is.. what do I do? Anyone know another link? Perhaps the given one is not functional anymore. Or maybe another way of doing this?

Maybe I already have the source files somewhere? Anything at all will do, really.

Thank you in advance.

EDIT: After running CMake, my lib and bin folders are still empty in the destination "Where to build the binaries". I have no idea why or how to fix this, if anyone does.. I will really appreciate it.