Let's say I have an image in a CBitmap with a color that signifies a transparent pixel (in my case it's magenta). Can I create a HRGN or a CRgn for the image that includes all the pixels except the magenta ones?
Can I create a HRGN/CRgn by excluding all the magenta pixels in a given image?
647 views Asked by sashoalm At
2
There are 2 answers
0

At its simplest, you need to call CreateRectRgn
multiple times, passing a single-pixel rectangle for each magenta pixel. You'd then combine these regions together using CombineRgn
.
Obvious optimisations include:
- using a DIB section, rather than
GetPixel
to scan the original image. - looking for single-row runs of the same pixel, so that you're not combining 1 x 1 regions.
- looking for multi-row blocks of the same pixel, so that you're not combining 1 x n regions.
That said: why do you need an HRGN? Could you get away with just transforming the original bitmap into a mask bitmap?
Related Questions in C++
- Transformer augmented cGAN
- How to train a model for a dataset of images with 12 bands using TensorFlow's pix2pix notebook?
- I want to optimize the conditon gan model (generator),error: shape '[64, 3, 64, 64]' is invalid for input of size 2952192 ,
- Data cardinality is ambiguous: x sizes: 15, 15 y sizes: 30 Make sure all arrays contain the same number of samples
- ValueError: Input 0 of layer “Discriminator” is incompatible with the layer: expected shape=(None, 3), found shape=(100, 2)
- best way of using float as the conditional input for cGAN? one-hot encoder?
- Implementation of the discriminator in CGAN
- In layers.append(nn.BatchNorm1d(out_feat, 0.8)) and layers.append(nn.LeakyReLU(0.2, inplace=True)) What is meant by 0.8 and 0.2?
- Non-frontal Facial landmark prediction
- Python Tensorflow error "Input 0 of layer "dense" is incompatible with the layer: expected min_ndim=2, found ndim=1."
Related Questions in WINAPI
- Transformer augmented cGAN
- How to train a model for a dataset of images with 12 bands using TensorFlow's pix2pix notebook?
- I want to optimize the conditon gan model (generator),error: shape '[64, 3, 64, 64]' is invalid for input of size 2952192 ,
- Data cardinality is ambiguous: x sizes: 15, 15 y sizes: 30 Make sure all arrays contain the same number of samples
- ValueError: Input 0 of layer “Discriminator” is incompatible with the layer: expected shape=(None, 3), found shape=(100, 2)
- best way of using float as the conditional input for cGAN? one-hot encoder?
- Implementation of the discriminator in CGAN
- In layers.append(nn.BatchNorm1d(out_feat, 0.8)) and layers.append(nn.LeakyReLU(0.2, inplace=True)) What is meant by 0.8 and 0.2?
- Non-frontal Facial landmark prediction
- Python Tensorflow error "Input 0 of layer "dense" is incompatible with the layer: expected min_ndim=2, found ndim=1."
Related Questions in MFC
- Transformer augmented cGAN
- How to train a model for a dataset of images with 12 bands using TensorFlow's pix2pix notebook?
- I want to optimize the conditon gan model (generator),error: shape '[64, 3, 64, 64]' is invalid for input of size 2952192 ,
- Data cardinality is ambiguous: x sizes: 15, 15 y sizes: 30 Make sure all arrays contain the same number of samples
- ValueError: Input 0 of layer “Discriminator” is incompatible with the layer: expected shape=(None, 3), found shape=(100, 2)
- best way of using float as the conditional input for cGAN? one-hot encoder?
- Implementation of the discriminator in CGAN
- In layers.append(nn.BatchNorm1d(out_feat, 0.8)) and layers.append(nn.LeakyReLU(0.2, inplace=True)) What is meant by 0.8 and 0.2?
- Non-frontal Facial landmark prediction
- Python Tensorflow error "Input 0 of layer "dense" is incompatible with the layer: expected min_ndim=2, found ndim=1."
Related Questions in TRANSPARENT
- Transformer augmented cGAN
- How to train a model for a dataset of images with 12 bands using TensorFlow's pix2pix notebook?
- I want to optimize the conditon gan model (generator),error: shape '[64, 3, 64, 64]' is invalid for input of size 2952192 ,
- Data cardinality is ambiguous: x sizes: 15, 15 y sizes: 30 Make sure all arrays contain the same number of samples
- ValueError: Input 0 of layer “Discriminator” is incompatible with the layer: expected shape=(None, 3), found shape=(100, 2)
- best way of using float as the conditional input for cGAN? one-hot encoder?
- Implementation of the discriminator in CGAN
- In layers.append(nn.BatchNorm1d(out_feat, 0.8)) and layers.append(nn.LeakyReLU(0.2, inplace=True)) What is meant by 0.8 and 0.2?
- Non-frontal Facial landmark prediction
- Python Tensorflow error "Input 0 of layer "dense" is incompatible with the layer: expected min_ndim=2, found ndim=1."
Related Questions in REGIONS
- Transformer augmented cGAN
- How to train a model for a dataset of images with 12 bands using TensorFlow's pix2pix notebook?
- I want to optimize the conditon gan model (generator),error: shape '[64, 3, 64, 64]' is invalid for input of size 2952192 ,
- Data cardinality is ambiguous: x sizes: 15, 15 y sizes: 30 Make sure all arrays contain the same number of samples
- ValueError: Input 0 of layer “Discriminator” is incompatible with the layer: expected shape=(None, 3), found shape=(100, 2)
- best way of using float as the conditional input for cGAN? one-hot encoder?
- Implementation of the discriminator in CGAN
- In layers.append(nn.BatchNorm1d(out_feat, 0.8)) and layers.append(nn.LeakyReLU(0.2, inplace=True)) What is meant by 0.8 and 0.2?
- Non-frontal Facial landmark prediction
- Python Tensorflow error "Input 0 of layer "dense" is incompatible with the layer: expected min_ndim=2, found ndim=1."
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Popular Tags
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
The only way to do this is to scan over the image, row at a time, scanning pixels and keep on combining pixel ranges into a HRGN object.
You will want to do this with a DIBSection as calling GetPixel is rather slow.