JohnDMcMaster/faxitron

Review bad pixel replace

JohnDMcMaster opened this issue · 1 comments

Think it isn't working correctly near edges. Also performance could be significantly improved

fixed. Was:

    return statistics.median(pixs)

Now:

    return int(statistics.median(pixs))

Given some previous caching weirdness I've experienced with np and such, I was nervous about this earlier so I verified it was an int just in case, and it was. However, after adding some debug info the bad pixel replace step was adding negative pixels! And it was clearly related to the median function. This seems to fix it

Alex also was reporting:

Traceback (most recent call last):
  File "ham_process.py", line 151, in <module>
    main()
  File "ham_process.py", line 146, in main
    run(args.dir_in, args.fn_out, cal_dir=args.cal_dir, hist_eq=args.hist_eq, invert=args.invert, hist_eq_roi=util.parse_roi(args.hist_eq_roi), scalar=args.scalar, rescale=args.rescale, bpr=args.bpr, raw=args.raw)
  File "ham_process.py", line 107, in run
    im_wip = do_bpr(im_wip, badimg)
  File "ham_process.py", line 55, in do_bpr
    ret.putpixel((x, y), im_med3(im, x, y))
  File "/usr/local/lib/python3.7/site-packages/PIL/Image.py", line 1753, in putpixel
    return self.im.putpixel(xy, value)
SystemError: <method 'putpixel' of 'ImagingCore' objects> returned NULL without setting an error

And this seems to have fixed his error as well. Huzah!