Skip to content
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

Added functions 'cudaSplit' and 'cudaMerge' #39

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

HiroshiYAMA
Copy link
Contributor

cudaSplit

This function splits from RGB/RGBA image to each color images, or splits to 3 color image and alpha channel image.
BGR/BGRA image is also okay.

cudaMerge

This function merges from each color images to RGB/RGBA image, or merges from 3 color image and alpha chennel image.
BGR/BGRA image is also okay.

Example1,
Python

# split.
img_IN = jetson.utils.loadImage('src.jpg', format='rgba8')
W = img_IN.width
H = img_IN.height
CH = img_IN.channels
img_SPLIT = [jetson.utils.cudaAllocMapped(width=W, height=H, format='gray8') for i in range(CH)]
jetson.utils.cudaSplit(img_IN, img_SPLIT)
jetson.utils.cudaDeviceSynchronize()

# merge.
img_OUT = jetson.utils.cudaAllocMapped(width=W, height=H, format='rgba8')
jetson.utils.cudaMerge(img_SPLIT, img_OUT)
jetson.utils.cudaDeviceSynchronize()

Example2,
Python

# split.
img_IN = jetson.utils.loadImage('src.jpg', format='rgba32f')
W = img_IN.width
H = img_IN.height
CH = img_IN.channels
img_COLOR = jetson.utils.cudaAllocMapped(width=W, height=H, format='rgb32f')
img_ALPHA = jetson.utils.cudaAllocMapped(width=W, height=H, format='gray32f')
jetson.utils.cudaSplit(img_IN, img_COLOR, img_ALPHA)
jetson.utils.cudaDeviceSynchronize()

# merge.
img_OUT = jetson.utils.cudaAllocMapped(width=W, height=H, format='rgba32f')
jetson.utils.cudaMerge(img_COLOR, img_OUT, img_ALPHA)
jetson.utils.cudaDeviceSynchronize()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant