Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6917657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:45:29+00:00 2026-05-27T09:45:29+00:00

At the moment I use: transparent // ClearAll transparent[i_] := Module[{r, g, b, a},

  • 0

At the moment I use:

transparent // ClearAll
transparent[i_] :=
 Module[{r, g, b, a},
  {r, g, b} = ImageData /@ ColorSeparate[i, "RGB"];
  a = Unitize[3. - (r + g + b)];
  (Image /@ {r, g, b, a})~ColorCombine~"RGB"
  ]
  1. Is there a way to play with the shape of what ImageData returns to eliminate ColorSeparate / ColorCombine in the above?
  2. Are there improvements or wholly other methods you could come up with that are as fast as or faster than the above?

Note: the function makes only perfectly white RGB pixels transparent and that is intended.

Update about first question:

ColorSeparate, ColorCombine can be eliminated by using Interleaving->False

transparent0 // ClearAll
transparent0[i_] :=
 Module[{r, g, b, a},
  {r, g, b} = ImageData[i, Interleaving -> False];
  a = Unitize[3. - (r + g + b)];
  Image[{r, g, b, a}, Interleaving -> False, ColorSpace -> "RGB"]
  ]

but performance is worse:

transparent0[img]; //Timing
(* ==> {0.6490372, Null} *)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:45:29+00:00Added an answer on May 27, 2026 at 9:45 am

    What version of Mathematica are you using? In Mathematica 8 you could use SetAlphaChannel. For example

    transparent2[img_] := SetAlphaChannel[img, Binarize[ColorNegate[img], 0.]]
    

    would set the alpha channel of all white pixels to 0 and all other pixels to 1. I tested this on

    img = Image[Graphics3D[Sphere[], Background -> White], ImageSize -> 1000]
    

    and the timings I get are

    transparent2[img]; // Timing
    (* ==> {0.10067, Null} *)
    

    compared to the original code

    transparent[img]; //Timing
    (* ==> {0.202112, Null} *)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

At the moment I use SVN to manage java source code. Is there a
So right now I'm bashing my head - at the moment we use an
I have two nested loop in XSL like this, at this moment I use
At the moment when i use this, i have to re-launch the app to
At the moment I'm trying to figure out how use default and custom settings
I'm trying to use custom meta boxes in wordpress. My goal at the moment
I need to decide which configuration framework to use. At the moment I am
I'm using jRuby at the moment (version 1.6.5) on my local machine. rvm use
Our company builds custom Java EE web solutions. At the moment, we use standard
There is a moment in my app, that I need to force to show

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.