Whole cursor is transparent - why? - unity3d

I'm trying to do simple thing - replace default cursor with my cursor, this is what I'm doing:
I prepared simple 64x64 png image:
Settings from Unity:
What I'm seeing in Game View
I'm setting this cursor through the code using this simple line:
Cursor.SetCursor(CursorTexture, CursorHotspot, CursorMode.Auto);
My goal is to remove just black background and leave star as it is, without making it transparent..
Do you have any idea how to solve this problem ?

The Unity documentation over here says that:
From Gray Scale
This generates the alpha from the mean (average) of the input Texture RGB values.
So the alpha of your image is the average of all of your Texture's RGB values.
Is there a reason you can't simply use a .png image with a transparent background instead?

Related

Uneven background correction using Top hats

I am trying to correct uneven background illumination in the text document using Morphological top-hat operation.
After applying Top hat, result I get is worse for analysis than the original image.
img=rgb2gray(imread("test2.png"));
se=strel("square",100);
imshow(imtophat(img,se));
Could you please advice what i am doing wrong ?
The top hat filter works for light text on a black background. You can either invert the image (imcomplement) before applying the top hat, or use imbothat instead.
In either case, the output is identical: light text on a black background. You can invert the image after the operation to get dark text on a white background.

Read "simple" transparent PNG in Matlab

I am trying to use PNG images as Toolbar icons. I am currently reading them with imread an set the corresponding CData value.
Now I have some images with transparency. There is no alpha channel (I found some threads with solutions for that), but I get some kind of "Simple Transparency". The imfread function returns "simple" for the Transparency field and a vector of values between 0 and 1 for the SimpleTransparencyData field.
I couldn't find any information about this transparency type neither in the Matlab help nor the internet. So I would like to know if it is possible to show the transparent image in the toolbar directly, or if not how to composite the transparent values with the toolbar's background color.
In summary you set the CData value to be a NaN to represent transparency.
See this article that I wrote on undocumentedmatlab.com which describes how to do it for uicontrols.
For a toolbar icon you modify the CData property in the same way - the primary difference is that you dont need to modify the backgroundcolor property.
I did a quick test on the only solution I could probably imagine and it really seems to work:
I forgot to mention, that I am using indexed PNG files for this. But this sort of transparency seems to imply this fact.
The indexed colors are ordered that the (partially) transparent colors are at the beginning of the table. The SimpleTransparencyData now specifies the transparency of each of the indexed colors. Non-transparent colors are left out, as there are more colors than transparency values.
With that additional information it is easy to composite a single background color with the image.

Image segmentation in matlab

I am trying to extract just the currency image from the an image of a currency taken on white paper. I tried median filter to get the background and use a simple subtraction like:
image=image-background.
But I got two problems: 1) The median filter is too slow. 2) The resulting image is not as my expectation.
Here is the image:
Any better way to do it, please?
You can try detecting the boundary of the note using edge detection and the hough transform. Alternatively, you can find the boundary using the activecontour function.
Another possibility is to detect the note using hue, using the fact that it is green and the background is not. Transform the image to HSV color space using rgb2hsv, and then use greythresh on the hue component.
By the way, this is more of an image segmentation problem. Background subtraction usually refers to separating moving objects from a static background in video.

iPhone iOS how to instantiate a black and white CGColorSpaceRef?

I'm working with this excellent example of converting an image to grayscale: Convert Image to B&W problem CGContext - iPhone Dev
However, for my purposes, I would like to have only pure black and pure white left in the image.
It appears that to do so, I need to pass a black and white color space to the recolor method using a call:
CGColorSpaceRef colorSpace = CGColorSpaceCreateWithName(/*black and white name*/);
However, I was unable to find the proper iOS color space names. What I found was from Mac, and the "color space names" referenced from the iOS docs does not point anywhere.
How can I properly create a black and white CGColorSpaceRef?
Thank you!
I am not familiar with a black and white only color space but what you can do is calculate the total average RGB value from all the pixels (lets call it totalAvg) and use it as a threshold. Meaning for each pixel if its rgb average is greater than the calculated totalAvg than set it to pure white, otherwise set it to pure black.
I agree it is a bit of more work but thats whay I can think of unless you find the colorspace you are looking for.
You might try creating a gray color space, then creating an indexed color space with two colors (black and white, obviously) and using that.

How to convert a black and white photo that was originally colored, back to its original color?

I've converted a colored photo to black and white, and bolded the edges. Now i need to convert it back to its original color with the bolded edges. Is there any function in matlab which allows me to do so?
Once you remove the colour from an image, there is no possible way to automatically put it back. You're basically reducing a set of 16,777,216 colours to a set of 256 - on average each shade of grey has 65,536 equivalent colours, and without the original image there's no way to guess which it could be.
Now, if you were to take the bolded lines from your black-and-white image and paint them on top of the original coloured image, that might end up producing what you're looking for.
If what you are trying to do is to use some filter over the B/W image and then use that with the original color. I suggest you convert your image to a color space with Lightness channel that suits your needs (for example L*a*b* if you need the ligtness to be uniformly distributed regarding human recognition of differences) and apply your filter only over the Lightness channel.