OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Fri, 09 Sep 2016 09:47:39 -0500Change pixel x,y location with mathematical functionhttp://answers.opencv.org/question/102020/change-pixel-xy-location-with-mathematical-function/ As the title suggests, I have an image, whose pixels I want to move based on a mathematical function. The code I use right now is consisted of two loops. And because of the nested loop, the process takes forever, -to be exact more than two minutes most of the times-, having in mind that each image has 12000 pixels to run through the loops. Is there another way to do this? I looked through the documentation but couldn't find anything.
imgcor = np.zeros(img.shape, dtype=img.dtype)
for f in range(rowc):
for k in range(colc):
offX = k + (f*b*c*(math.sin(math.radians(a))))
offY = f + (f*b*d*(math.cos(math.radians(a))))
imgcor[f, k] = img[int(offY)%rowc, int(offX)%colc]
The a,b,c,d values are certain parameters that are assigned earlier in the script.
P.S. I am using Python2.7 and opencv 2.4n.argiropFri, 09 Sep 2016 09:47:39 -0500http://answers.opencv.org/question/102020/