python


memory error - Scikit-image morphology reconstruction


I am writing a code for image segmentation; that script works pretty well with small images but with big images it gives that error message:
C:\Python27\python.exe "C:/Users/fabio.panella/Desktop/20161220 - Data
Reprocessed/Project_0/Python/Mele.py"
Traceback (most recent call last):
File "C:/Users/fabio.panella/Desktop/20161220 - Data
Reprocessed/Project_0/Python/Mele.py", line 39, in <module>
Iobr = skimage.morphology.reconstruction(Ie, BW)
File "C:\Python27\lib\site-
packages\skimage\morphology\greyreconstruct.py", line 189, in reconstruction
value_rank, value_map = rank_order(images)
File "C:\Python27\lib\site-packages\skimage\filters\_rank_order.py", line
50, in rank_order
sort_order = flat_image.argsort().astype(np.uint32)
MemoryError
Someone (How can i solve a memory error of python scikit image function color.rgb2gray()?) already ask about a similar problem but the answers didn't help me.
the code is:
# code #
import numpy as np
import cv2
import pymorph
import skimage
from skimage import morphology, measure
I = cv2.imread('ActiOn_45.jpg', 0)
# higher contrast #
u = np.float64(I)
OriRows, OriCols = u.shape[:2]
r1 = 30
r2 = 220
s1 = 0
s2 = 255
for i in range(1,OriRows):
for j in range (1, OriCols):
if u.item(i,j) < r1:
u[i, j] = s1
elif u.item(i,j) > r2:
u[i, j] = s2
else:
u[i, j] = s2*(u.item(i,j)-r1)/(r2-r1)
Ispreadmat = np.uint8(u)
ret, Black_Base = cv2.threshold(I, 255, 0, cv2.THRESH_TOZERO)
img_filtered = cv2.medianBlur(Ispreadmat, 5)
BW = cv2.adaptiveThreshold(img_filtered, maxValue=255, adaptiveMethod=cv2.ADAPTIVE_THRESH_GAUSSIAN_C, thresholdType=cv2.THRESH_BINARY_INV,blockSize=51,C=10)
# Morphological Transformation for opening-closing-by-reconstruction #
F = Black_Base
for a in xrange(0, 180, 10):
se = pymorph.seline(12, a)
Io = cv2.morphologyEx(BW, cv2.MORPH_OPEN, se)
Ie = cv2.morphologyEx(BW, cv2.MORPH_ERODE, se)
Iobr = skimage.morphology.reconstruction(Ie, BW)
Iobrd = cv2.dilate(Iobr, se, iterations=1)
Inv_Iobrd = 255 - Iobrd
Inv_Iobr = 255 - Iobr
Iobrcbr = skimage.morphology.reconstruction(Inv_Iobrd, Inv_Iobr)
Iobrcbr = 255 - Iobrcbr
Iobrcbr = np.uint8(Iobrcbr)
F = F + Iobrcbr
ret, bw = cv2.threshold(F, 127, 255, cv2.THRESH_BINARY)
cv2.imshow('Result', bw)
cv2.waitKey(0)
# end of the code
How can I solve this problem?
P.S. as example I was using the following picture: http://www.chemcosystems.com/images/photos/NEW2014/concrete%20repair%20crack%20injection%20bridge%20lift.JPG

Related Links

Viewing other user profile
Python Tkinter, Stop a threading function
Python runtime warning when move unit test to a package
UserWarning on Django website for Raven client
Organise .rst files for sphinx?
Scatter Plot of a Specific Column in Python using matplotlib
How to make difference between email html body and html attachment in python?
Cobb-Douglas maximization in python
Django won't serve some static files
Flask return SUM into Jinja2 list
i tried this sql request on python but is not working
Passing command line arguments in python by pytest
Not using grid anywhere in class still gives error 'cannot use geometry manager pack inside . which already has slaves managed by grid' in tkinter
Minimax Alogrithm for TicTacToe [python]
Zero Crossings Rate
Recursive function with one argument that does something to each element

Categories

HOME
converter
rest
cakephp-3.x
ajax
scipy
nuxeo
windows-7
formal-verification
matplotlib
csvhelper
sequelize.js
subquery
goutte
shipping
criteria
hosts
window
uiscrollview
nuxt.js
event-log
pdo
jquery-terminal
arm-template
ms-access-2007
movies
ios10.3
rworldmap
csh
scalajs-react
shopping-cart
printdocument
mef2
forum
spreedly
modulo
recurrence-relation
powershell-remoting
office365connectors
zero
codesys
topic-modeling
excel-interop
asmx
greenhills
windows-95
hpcc
emoticons
gmt
festival
shinyjs
keycode
build-process
cjson
alter
mailcatcher
software-product-lines
try-finally
radians
inotifypropertychanged
dbscan
asp.net-mvc-partialview
post-processing
android-recyclerview
cctray
plone-3.x
jenkins-scriptler
geodjango
enyo
programming-paradigms
swift2.1
candidate-key
omnifocus
node-imagemagick
dache
surrogate-key
slick-2.0
svcutil.exe
visual-c++-2010-express
dig
surveyor-gem
xslkey
android-contextmenu
icsharpcode
pys60
socketstream
linkedhashset
n-layer
userid
shared-objects
squeel
symbol-server
chatroom
mvccontrib-grid
querypath
revert
yajl
trampolines
iphone-sdk-3.2
divx

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App