Divide an image into lower regions
Hi,
I explain my problem, I have an image of MxN and I want ti create regions of lower dimensions. for example I want to divide the image into 4x2, so 8 regions I have the next code:
# Numbers of rows
nRows = 4
# Number of columns
mCols = 2
# Reading image
img = cv2.imread('XXXX')
print img
# Dimensions of the image
sizeX = img.shape[0]
sizeY = img.shape[1]
print sizeX,sizeY
# Tam of Y region
regionY=sizeY/nRows
# Tam of X region
regionX = sizeX/mCols
# Total of regions
totalRegions = nRows* mCols
name = str(totalRegions)
for v in range (0,totalRegions):
for i in range(0,mCols):
for j in range(0, nRows):
name = str(totalRegions)
globals()[name]=img[0+mCols*v:mCols+(mCols*v)-1,
0+nRows*(v/nRows):nRows+(nRows*(v/nRows))-1]
totalRegions += -1
And now explain what is going wrong? All I see is a piece of code and an explanation of your desired result.
Sorry, I hadn't time so I wrote the problem without explaining the problem, I 'll do it right now:
the thing is, I don't know if there is an optimal method in openCV to do the job I wrote, I think the code is not too good. Just asking for another idea.
Thanks.
Could you please share the python piece of code if it worked for you, mine even after applying the C++ algorithm, is not working displaying a red screen, i.e red colored filled rectangles all over the image.
@Gigi, it's not working like this. all those persons moved on, and won't ever respond.
ask your own question, show, what you've tried so far.