-
Notifications
You must be signed in to change notification settings - Fork 6
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
can't understand the function 'extract_tile' in loader.py #3
Comments
The array 'pos' stores the row-column postions of the patches that are generated by a sliding window with a step length of 'step'. So, 'pos * step' indicates the x-y coordinate of the patch on the WSI. The function 'extract_tile' is used to load a patch in the given position and given size. It is specific for our file struture where the WSI is stored in separated tiles. You may rewrite the function to fit your file structure. |
The array 'pos' stores the row-column positions of the patches that are generated by a sliding window with a step length of 'step'. So, 'pos * step' indicates the x-y coordinate of the patch on the WSI.
The function 'extract_tile' is used to load a patch in the given position and given size. It is specific for our file structure where the WSI is stored in separated tiles. You may rewrite the function to fit your file structure.
发件人: ***@***.*** ***@***.***> 代表 bytedance
发送时间: 2023年4月4日 22:33
收件人: Zhengyushan/kat ***@***.***>
抄送: Subscribed ***@***.***>
主题: [Zhengyushan/kat] can't understand the function 'extract_tile' in loader.py (Issue #3)
def extract_tile(image_dir, tile_size, x, y, width, height):
x_start_tile = x // tile_size
y_start_tile = y // tile_size
x_end_tile = (x + width) // tile_size
y_end_tile = (y + height) // tile_size
tmp_image = np.ones(
((y_end_tile - y_start_tile + 1) * tile_size, (x_end_tile - x_start_tile + 1) * tile_size, 3),
np.uint8) * 240
for y_id, col in enumerate(range(x_start_tile, x_end_tile + 1)):
for x_id, row in enumerate(range(y_start_tile, y_end_tile + 1)):
img_path = os.path.join(image_dir, '{:04d}_{:04d}.jpg'.format(row, col))
if not os.path.exists(img_path):
continue
img = cv2.imread(img_path)
h, w, _ = img.shape
tmp_image[(x_id * tile_size):(x_id * tile_size + h), (y_id * tile_size):(y_id * tile_size + w), :] = img
x_off = x % tile_size
y_off = y % tile_size
output = tmp_image[y_off:y_off + height, x_off:x_off + width]
return output
what's the meaning of 'pos[1] * step' in the below function? why you regard it as x and pass it to function extract_file?
def extract_and_save_tiles(image_dir, slide_save_dir, position_list, tile_size,
imsize, step, invert_rgb=False):
for pos in position_list:
img = extract_tile(image_dir, tile_size, pos[1] * step, pos[0] * step,
imsize, imsize)
if len(img) > 0:
if invert_rgb:
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
cv2.imwrite(
os.path.join(slide_save_dir, '{:04d}_{:04d}.jpg'.format(pos[1], pos[0])), img)
—
Reply to this email directly, view it on GitHub <#3> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AG6JCPATTRLXEUPGI2XDFTTW7QWKTANCNFSM6AAAAAAWSZXRPY> .
You are receiving this because you are subscribed to this thread. <https://github.com/notifications/beacon/AG6JCPGZOO7WCPO7S57IWBLW7QWKTA5CNFSM6AAAAAAWSZXRP2WGG33NNVSW45C7OR4XAZNFJFZXG5LFVJRW63LNMVXHIX3JMTHGFFR6FA.gif> Message ID: ***@***.*** ***@***.***> >
|
def extract_tile(image_dir, tile_size, x, y, width, height):
x_start_tile = x // tile_size
y_start_tile = y // tile_size
x_end_tile = (x + width) // tile_size
y_end_tile = (y + height) // tile_size
what's the meaning of 'pos[1] * step' in the below function? why you regard it as x and pass it to function extract_file?
def extract_and_save_tiles(image_dir, slide_save_dir, position_list, tile_size,
imsize, step, invert_rgb=False):
for pos in position_list:
img = extract_tile(image_dir, tile_size, pos[1] * step, pos[0] * step,
imsize, imsize)
The text was updated successfully, but these errors were encountered: