On Sat, 6 May 2017 10:24:51 +0000
Subhradeep Dutta <bazlightyear117(a)outlook.com> wrote:
> I am trying to write a CUDA kernel for computing a piece of Python code. I would need to sort the data inside the kernel but since there are no built in functions that would sort the data so I am not sure what would be the best way to implement this. Any suggestions on how to implement it would be appreciated. Feel free to put some sample code or point me to online resources that have a similar problem.
>
>
> for i in xrange(0,img_size_x-window_size):
> for j in xrange(0,img_size_y-window_size):
> kernel = img[i:i+window_size,j:j+window_size]
> kernel_flat = np.sort(kernel.flatten())
> # Calculate the rank
> rank = np.where(kernel_flat == img[i,j])[0][0]
> img_mod[i,j] = int((rank * 255 )/(window_size_squared))
There are a couple of sort available in parallel, among them the
bitonic-sort is pretty well adapted to this kind of problems.
Your code looks like a median filter. Resources are available on the
net about this.
Cheers,
--
Jérôme Kieffer
tel +33 476 882 445
I am trying to write a CUDA kernel for computing a piece of Python code. I would need to sort the data inside the kernel but since there are no built in functions that would sort the data so I am not sure what would be the best way to implement this. Any suggestions on how to implement it would be appreciated. Feel free to put some sample code or point me to online resources that have a similar problem.
for i in xrange(0,img_size_x-window_size):
for j in xrange(0,img_size_y-window_size):
kernel = img[i:i+window_size,j:j+window_size]
kernel_flat = np.sort(kernel.flatten())
# Calculate the rank
rank = np.where(kernel_flat == img[i,j])[0][0]
img_mod[i,j] = int((rank * 255 )/(window_size_squared))
Thanks
Hi!
SAHIL wants to follow your academic work and collaborate on Authorea.
In order to join them, please fill-in your account details by clicking on the link below:
http://www.authorea.com/activate_accounts/UeN-IKLGEC-t_3FAe1H5Ww/edit
This link will be valid for one week. If you still haven't verified your account by then, please email us at help(a)authorea.com and we'll be happy to help you out.
Happy Writing!
Authorea
Authorea, Inc.
97 South 6th, 3rd floor
Brooklyn, NY 11249.
hi(a)authorea.com