1

I'm trying to process images and try them to save them. I am able to process it but image are not getting saved in folder

code - Taken from github

import cv2, glob, numpy

def scaleRadius(img,scale):
    x=img[int(img.shape[0]/2),:,:].sum(1)
    r=(x>x.mean()/10).sum()/2
    s=scale*1.0/r
    return cv2.resize(img,(0,0),fx=s,fy=s)

scale =512
for f in (glob.glob("pdr/*.jpeg")):

    a=cv2.imread(f)
    a=scaleRadius(a,scale)
    b=numpy.zeros(a.shape)
    cv2.circle(b,(int(a.shape[1]/2),int(a.shape[0]/2)),int(scale*0.9),(1,1,1),-1,8,0)
    aa=cv2.addWeighted(a,4,cv2.GaussianBlur(a,(0,0),scale/30),-4,128)*b+128*(1-b)
    cv2.imwrite(str(scale)+"_"+f,aa)

Code executes well but it output does not get saved

1
  • 2
    You ought to pass a proper path inside cv2.imwrite() in order to save the images. The code on github was posted to guide others using it. That does not mean you blindly copy it and expect it to work wonders. Commented Jun 3, 2018 at 17:49

1 Answer 1

1

cv2.imwrite() doesn't create the directory for you, make sure you've created directory 512_pdr before running the script.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.