StrokeWidthTransform
StrokeWidthTransform copied to clipboard
Urgent :memory Error
I am trying to run the code in python. But,I am getting memory error in executing the 'Union' function. please help.very urgent Otherwise please provide alternative implementation of SWT in python.
Thanks
Hi, I also meet this question ,and i'm debugging to solve it.
Okay,Please tell me if you get a solution. I think the image size is too big to read. Also there are many more errors in the code it seems and needs modifications.
@chitransh1998 See the Outofmemory error Issue. Some one provided the modified code.
Hi, i am getting memory error when trying to run this code in python. This function manly
def _find_letters(cls, swt, shapes, shape_h, shape_w): # STEP: Discard shapes that are probably not letters swts = [] heights = [] widths = [] topleft_pts = [] images = []
for label,layer in shapes.items():
(nz_y, nz_x) = (layer[0],layer[1])
east, west, south, north = max(nz_x), min(nz_x), max(nz_y), min(nz_y)
width, height = east - west, south - north
if width < 4 or height < 4:
continue
if width / height > 10 or height / width > 10:
continue
diameter = math.sqrt(width * width + height * height)
median_swt = np.median(swt[(nz_y, nz_x)])
swts.append([math.log(median_swt, 2)])
heights.append([math.log(height, 2)])
topleft_pts.append(np.asarray([north, west]))
widths.append(width)
fulllayer = np.zeros((shape_w, shape_h), dtype=np.uint16)
for i in range(len(layer[0])):
fulllayer[layer[0][i], layer[1][i]] = 1
images.append(fulllayer)
return swts, heights, widths, topleft_pts, images