Python Forum
How to process the array correctly
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to process the array correctly
#1
Photo 
import numpy as np
from timeit import default_timer as timer

mask = np.load('mask.npy', allow_pickle=True)

cell_mask_new_all = mask[:, :, :].astype(np.uint8)
cell_mask_one = cell_mask_new_all[:,:,186]

cell_mask_two = np.uint8(mask[:, :, 186])


t_1 = timer()
image_cell_mask_one = cell_mask_one*255
t_2 = timer()
print('image_cell_mask_one time:', t_2 - t_1)

t_3 = timer()
image_cell_mask_two = cell_mask_two*255
t_4 = timer()
print('image_cell_mask_two time:', t_4 - t_3)
I found a very interesting question. As you see, I use different code to get Cell_mask_one and Cell_mask_two, but the time of they multiply 255 is very difference.

I can not upload the img, and Write it out by hand。

t_1 = timer()
image_cell_mask_one = cell_mask_one*255
t_2 = timer()
print('image_cell_mask_one time:', t_2 - t_1)
0.04487754100409802

t_3 = timer()
image_cell_mask_two = cell_mask_two*255
t_4 = timer()
print('image_cell_mask_two time:', t_4 - t_3)
0.002681313009816222

The memory of data is almost 898mb,I can't upload here. I put the data at the google drive.
https://drive.google.com/file/d/1LyJxMiW...sp=sharing
Would you help me?Thanks.

Attached Files

.py   array_compare.py (Size: 480 bytes / Downloads: 284)
Reply


Messages In This Thread
How to process the array correctly - by Fly_jia - Jun-07-2021, 08:25 AM
RE: How to process the array correctly - by Fly_jia - Jun-09-2021, 01:40 AM
RE: How to process the array correctly - by Fly_jia - Jun-09-2021, 01:47 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to sharing object between multiple process from main process using Pipe Subrata 1 3,748 Sep-03-2019, 09:49 PM
Last Post: woooee

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020