I am working with Python 3.4 at Ubuntu 14.04 (Nampi 1.9.2 and PIL.Engase 1.1.7). What do I do here:
gt; & Gt; Image from PIL import & gt; & Gt; & Gt; Np & gt; & Gt; & Gt; Img = Image.open ("./tifs / 18015.pdf_001.tif")> gt; & Gt; & Gt; Arr = np.asarray (img) & gt; & Gt; & Gt; Np.shape (arr) (5847, 4133) & gt; & Gt; & Gt; Arr.dtype dtype ('bool') # In the following four cases where I continually increase # number of rows immediately 700 and immediately; Gt; & Gt; & Gt; V = arr [1: 100,1: 100] .sum (axis = 0)> gt; & Gt; & Gt; V = arr [1: 500,1: 100] .sum (axis = 0)> gt; & Gt; & Gt; V = arr [1: 600,1: 100] .sum (axis = 0)> gt; & Gt; & Gt; V = arr [1: 700,1: 100] .sum (axis = 0) # But suddenly this line is called Python Crash & gt; & Gt; & Gt; V = arr [1: 800,1: 100] .sum (axis = 0) Fish: Job 1, "Python 3" signal ended by SIGSEGV (address boundary error)
I think the dragon suddenly runs out of memory if this is the case - how can I allocate more memory to Python? As I can see from my 32GB memory capacity HOP, even remotely can not be reduced.
You can download TIFF image.
If I am creating an empty Boolean array, then set the pixel clear and then apply the conference - then it works:
> Gt; & Gt; Arr = np.empty ((h, w), dtype = bool)> gt; & Gt; & Gt; Arr.setflags (type = true)> gt; & Gt; & Gt; For R in Category (H): & gt; & Gt; & Gt; Limit for C (W): & gt; & Gt; & Gt; Arr.itemset ((r, c), img.getpixel ((c, r))) gt; & Gt; & Gt; V = arr.sum (axis = 0) >> gt; & Gt; V.mean () 5726.8618436970719 & gt; & Gt; & Gt; Arr.shape (5847, 4133)
But this "solution" is not very satisfactory in copying every pixel, possibly a faster way?
No comments:
Post a Comment