I edited a simple png image with gimp, but it made transparent background black. So I tried undo'ing it, but nothing changed. Then I completely deleted all pixels (ctrl+A and delete) - this made image completely blank (white). But then I read it with OpenCV (python, ubuntu 16.04) and I still could see that old picture!
This is simple code I used to read image. As you can see it is completely blank (white).
But then I run the code and I can still see the old picture!
Here you can see - it is completely empty. I opened it with Firefox, Gimp, default ubuntu image viewer, windows photo viewer - same blank image.
So I decided to try something and I drawed with Gimp on that picture:
And I ran same code again:
After undo'ing question mark image returned to same. I figured - it could be some software error - I rebooted - same. Then I copied 'nothing.png' to Win10. Same code - same result. Image is about 449kB size. Here it is:
What the hell is going on here?
GIMP didn't erase the RGB data, it just sets the alpha channel to 0.
That's enough... unless you ignore the alpha channel.
OpenCV ignores the alpha channel... it's just another channel, not special at all. OpenCV can read and write RGBA data, and you can use the alpha channel like any other channel. It's just that display with imshow ignores the alpha channel and shows you the RGB data.
Related
Icons Are Pretty Right?
I'm working on an UI update in an iOS app, and trying to make things look a bit better with some new icons- but I seem to be incapable of determining how to save an image correctly so that it looks good in the interface!
As you can see from this image, if I include a white background with the image it looks great. If I take those same images and use an alpha background they look terrible! It appears that either the images aren't using the #2x correctly, or something else is going horribly wrong.
These images are either saved with GIMP as a png with alpha, or exported from inkscape, the originals are vector graphics. We get the same results from both avenues. I am using both a base imageName.png and imageName#2x.png for scaling.
Somehow, magically, I changed the a single image to greyscale in gimp, and changed the base size to 25px and it showed up with alpha correctly blended. Stock images from apple are also functioning correctly, so it absolutely seems to be something that I'm doing incorrectly when I'm saving the images.
The Setup in XCode
Basic Questions
Is there a certain bit depth, argb vs rgba format, or some other quirk that I need to know to get these images to show up correctly? Is there any way to verify that the program is loading the correct imageName#2x vs imageName? Is there some document that talks about integrated graphics (the iconography documentation isn't very helpful on technical details)
Actual Images
With Background:
Without Background:
I think you will find success if you just save the image at 4x the size you actually want and specify the size manually.
I was messing around with the RGB channels in photoshop and found what I wanted when I removed visibility of the red channel, and kept blue and green. When I went to save my image it saved it in complete RGB. How do I temporarily remove the red channel from the image for saving? I have attached a pic for help. Thanks,
Before,
How I want it saved,
By definition if you are working with typical RGB images you have 3 channels of colors. You cannot erase one channel, keep the rest two channels and still have a valid image (in the strict RGB sense).
If you need to eliminate the information in one channel you just have to turn it to black. In your case, if you need to eliminate channel Red, then just select the Red channel and fill it completely with black color (ex. use the bucket fill with 255 tolerance). You will still end up with a 3-channel (or 4-channel if you have transparency) image but without any information from the Red channel.
i think you probably have the answer by this time but for the others.
after hide the unwanted channels click on image select all with CTRL+A then copy with CTRL+C and create a new layer paste it with CTRL+V and you're done!
I have a solution but it's not recommended:
Goto Adobe: View/Screen Mode/Full screen mode.
On the keyboard press Print Screen.
In Adobe open new file or press Ctrl+N and make settings as you want.
Tip: For high resolution, change Resolution to higher than 300 and press Ctrl+V and you are done.
Crop or Resize your picture and save it.
Tip: Press Shift while resizing to keep the picture in its original condition!
I'm using the color information in the texture still when the alpha is set to 0. The PNG file is correctly saved with the color preserved. If I use the content pipeline and set it to non-premultiplied, everything works fine. Texture2D.FromStream is documented as non-premultiplied but it's wiping out the color. When debugging in PIX and looking at the texture, all pixels with 0 alpha are set to black.
Is there a way I can bypass the content pipeline and still keep my color for transparent pixels?
I'm not able to help too much just now as I don't have code in front of me but I done this a few days ago myself and it had all the correct transparency that was expected. Perhaps it's your image that has an issue? I used a PNG saved using Paint.Net.
As seen in this image http://imgur.com/Qrqqo the boat, tree trunk and ladder all have transparency which allow them to be on a second layer and the tileset itself is loaded using from stream (User generated content ftw).
So if no-one has answered this before I get to my computer with code then I'll take a look at what I have and post a sample if needed.
I have over 100k in images that at one time were cropped and had a white border applied to them. I'm looking for the best way to programmaticly process each image so that I can detect the white borders and either crop the border or fill in the border with black instead. Would I need to use something like OpenCV or just plain old GDI? I've attached an image for reference.
What I have to work with (White borders are there, trust me):
http://cdn-images.hollywood.com/site/SO_3666231.jpg
Plain old GDI should work just fine, except for one thing - I don't know how to make GDI save an image back to a file. When I've had to do it in the past I've written a .BMP file in pieces, which wouldn't work for a JPEG. Time for a new question?
You're going to need a two step process - first measure the white borders, then copy the image to a new image to get rid of them.
Starting with a JPEG image introduces two small problems. First is that the image will contain some decoding artifacts, and white won't always be an RGB value of (255,255,255). You'll need to establish a threshold, such as (250,250,250) and see how that works; if it doesn't catch all of the borders, you'll need to try a lower threshold. Second is that resaving the image as a JPEG will introduce additional artifacts, lowering the quality of the image. Hopefully this will be within acceptable limits, but only you can be the judge of that.
I'm sorry that this isn't really an answer, perhaps more like 1/4 of an answer. I hope you find it useful.
An image is copied from Firefox into the Clipboard. My program gets it from clipboard and saves as a JPEG image. For some reason the image is saved with a black background. If I open the same URL in IE and copy the image into the Clipboard, the image is saved correctly by my program. I am using Delphi 7.
I also tried to copy the image from Firefox into Microsoft Paint and again the black background. Does anyone has a tip in how to handle such problem.
I assume the original image is transparent? If so, you should be aware that JPEGs can't handle transparency. Try switching the output image type and seeing if you program magically goes away.
If you get the same background in your program and Paint, then that tells me this is something to do with Firefox, and thus it is not necessarily your problem to solve.
Since you're concerned about the background color, I guess the image you're copying has transparent elements to it. So tell me: What color should be there? A JPEG image can't have transparent parts, so every pixel must have some color. Firefox apparently chooses to put black there; how is that not a correct choice and Internet Explorer's is?
I wonder what color background you get when you paste into a more capable graphics program than Paint, such as Gimp or Photoshop. I would expect those programs to consider multiple clipboard formats and choose the most appropriate format, so they might choose a format that accommodates transparency when it's available. Your program and Paint, on the other hand, probably just use the cf_Bitmap format, which of course can't have transparent pixels, so they get whatever the copying program opted to use to fill in the blank space.
By the way, both Firefox and Internet Explorer allow you to drag an image directly from the browser to the desktop or other folder window to save the original image. Maybe that makes your program unnecessary?
I know this is a slightly old question, but I've just come across the same issue in Firefox v9.
Use the following workaround: save the image in question to your computer, then copy the file in explorer and paste in the program you want to use (in my case I pasted into word).