Make 32x32 sections on an image in C++ OpenCV?
Im trying to divide a passed in, gray scaled image and divide it into 32x32 "blocks" or "sections". Sort of like an imaginary, overlay grid.
Once this is done, I need to loop through each pixel in each individual section to perform analysis on the single channel, gray scale value that is returned by each pixel.
For example:
// For region (x,y)
if pixelVal >= 120 && pixelVal <= 130{
bitStream += "1"; }
else if pixelVal >= 135 && pixelVal <= 140{
bitstream += "0"; }
else{
bitStream += "X"; }
Does this make sense? I'm very new to OpenCV and C++ and basically I know how to show, loop through, and return the pixel value at a given point, just not within a certain, predetermined area. Im thinking about creating some sort of window that loops through? I just have no idea how to code it.
no, it does not quite make sense to me.
if you need an analysis per pixel, why the blocks then ?
if you need an analysis per block, why the pixels then ?
what are you trying to achieve here ? what's the context ?
and no, you should never iterate over pixels for anything, in opencv. there are always higher-level functions, that should be used instead.
1."why the blocks then?": Im going to take an average pixel count in the respective blocks. So say block (4,16) is averaging 210. 2. "why the pixels then": Analysis per block is necessary for error correcting methods later on. 3. "what are you trying to achieve here": It's a cryptographic key generator that Im basing off of a passed in image. If a block fits certain conditions, like the ones I laid out above, it's counted as a 1, 0, or X.