-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compressed RLE to uncompressed RLE #386
Comments
hi, have you solved it? I have the same problem |
Given the algorithm and some data you should be able to find the details. |
I also needed this so I created the following solution. It's not the cleanest of solutions but gets the job done.
def decompress(rleObjs):
cdef RLEs Rs = _frString(rleObjs)
rles, hs, ws = [], [], []
for i in range(Rs.n):
rles.append([Rs._R[i].cnts[j] for j in range(Rs._R[i].m)])
hs.append(Rs._R[i].h)
ws.append(Rs._R[i].w)
return rles, hs, ws
pip uninstall pycocotools
cd PythonAPI
make install
import pycocotools.mask as mask_util
import pycocotools._mask as _mask_util
import numpy as np
binary_mask = np.array([[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 1, 1, 1, 0, 0],
[ 0, 0, 0, 0, 0, 1, 1, 1, 0, 0],
[ 0, 0, 0, 0, 0, 1, 1, 1, 0, 0],
[ 0, 0, 0, 0, 0, 1, 1, 1, 0, 0],
[ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]], dtype=np.uint8)
fortran_binary_mask = np.asfortranarray(binary_mask)
compressed_rle = mask_util.encode(fortran_binary_mask)
decompressed_rles, heights, widths = _mask_util.decompress([compressed_rle]) |
I had the same issue, but it was quite simple. |
Hi,
As the title says, is there a way to go from compressed RLE to uncompressed RLE?
Or is there a way to decode the byte string returned by the "count" to return the array of integer counts?
Best regards.
The text was updated successfully, but these errors were encountered: