Placing objects around image highlights- coco2d /opengl / coregraphics? - iphone

I would like to extract the white areas/bright areas of an image and place a custom objects in those areas. I need to know which framework to work with. if anyone has done something similar, I would appreciate an answer. I know how to get Pixel values, however the hard part is creating a Bloom/star effect in those highlighted areas.

You could make a mask where the luminance value was above a threshold, then blur or whatever the mask and composite above the image.

Related

How to create a Sprite Color Mask in Unity

I'm trying to use the Among Us Spritesheets to get crewmates in Unity. The spritesheet looks like this: https://www.reddit.com/r/AmongUs/comments/ir6nl0/main_player_sprite_sheet_for_those_who_wanted_it/
Each sprite is a blue/red color. Somehow the devs get every color of crewmate from these sprites, and I'm wondering how they did it.
How can I get every color of crewmate from this sprite sheet?
Thanks!
EDIT: Solution
I edited the title to be more accurate to my problem. Thanks to #G Kalendar for mentioning Shaders, I hadn't thought about that.
What I ended up doing was creating a Shader Graph, extracting each color channel, multiplying it by a color value, and recombining them into a texture.
I followed this helpful and straightforward tutorial: https://www.youtube.com/watch?v=4dAGUxvsD24
This is what my Shader Graph ended up looking like:
"Secondary" and "Primary" are color properties.
Hope this helps somebody!
If you want to have multiple info stored in a single image, it's common practice to use the channels: Red, Green, Blue. Horizon Zero Dawn for example uses that technique to make the environment effects as efficient as possible.
Here it looks like blue and red are used as a polaceholder to mark an area. So in unity's shader graph, when you use this image in a SampleTexture2D node you can use a Split node to get the different channels of the image to isolate the parts you want to color in.
Then just multiply the different channels by the color you want, add them together and use that as the base color.
Edit: Or use the "Replace Color Node" I just learned about.

Unity Line Mesh Inward Shader

I am pretty new to shaders in unity and am stuck on a problem.
I am using ShaderGraph and unity 2021. I understood the ShaderGraph examples from the unity page and "implemented" an OutlineShader thinking I could simply "inverse" the direction (not multiply by some value to get a bigger object then coloring that object and laying the original object ontop). Yet I am nowhere near what I want.
Basically what I am trying to achive is a stepped color gradient to the inside of the object. As an image it should look something like this:
Starting from color0 (green) going inward to color1 (yellow) until i reach the center with colorN (white) and repeat the same for the other side. The shader is then used on a material that is applied to a MeshLineRenderer (LineRendererPro from asset store with minor modifications for custom behavior) which kind of looks like this:
In the end the line should be colored according to the specified colors and the direction the line is going.
Explanation of a simple "Inline" Shader (similar to an outline) would help alot. I think I would be able to adapt that concept and implement multiple colors with (maybe) percentages of width. I don't want to use a fixed image/texture since i want to change the widths and colors.
Any input is welcome and thank you in advance.

Detecting shape from the predefined shape and cropping the background

I have several images of the pugmark with lots of irrevelant background region. I cannot do intensity based algorithms to seperate background from the foreground.
I have tried several methods. one of them is detecting object in Homogeneous Intensity image
but this is not working with rough texture images like
http://img803.imageshack.us/img803/4654/p1030076b.jpg
http://imageshack.us/a/img802/5982/cub1.jpg
http://imageshack.us/a/img42/6530/cub2.jpg
Their could be three possible methods :
1) if i can reduce the roughness factor of the image and obtain the more smoother texture i.e more flat surface.
2) if i could detect the pugmark like shape in these images by defining rough pugmark shape in the database and then removing the background to obtain image like http://i.imgur.com/W0MFYmQ.png
3) if i could detect the regions with depth and separating them from the background based on difference in their depths.
please tell if any of these methods would work and if yes then how to implement them.
I have a hunch that this problem could benefit from using polynomial texture maps.
See here: http://www.hpl.hp.com/research/ptm/
You might want to consider top-down information in the process. See, for example, this work.
Looks like you're close enough from the pugmark, so I think that you should be able to detect pugmarks using Viola Jones algorithm. Maybe a PCA-like algorithm such as Eigenface would work too, even if you're not trying to recognize a particular pugmark it still can be used to tell whether or not there is a pugmark in the image.
Have you tried edge detection on your image ? I guess it should be possible to finetune Canny edge detector thresholds in order to get rid of the noise (if it's not good enough, low pass filter your image first), then do shape recognition on what remains (you would then be in the field of geometric feature learning and structural matching) Viola Jones and possibly PCA-like algorithm would be my first try though.

Drawing a color map with Core Graphics

I'm trying to figure out how to draw a color map like this: http://www.ritsplasman.com/images/colormap.png
I know Core Graphics has two functions that deal with gradients: CGContextDrawLinearGradient and CGContextDrawRadialGradient. A radial gradient is not what I want so I guess I'm forced to use the other one. But I cannot accomplish the example image using just a linear gradient.
The color map is basically a gradient where the hue changes horizontally and saturation vertically. How can I achieve this?
As its name implies, the linear gradient only goes on one axis. In theory you could stack multiple gradients on top of one another to create a similar effect as that image but I doubt that would be a very efficient solution to the problem. I needed a similar color map in one of my iOS apps, I ended up using the image because it was far more efficient then trying to recreate it.

Getting pixels data from image on iPhone

I want to use bitmap images as a "map" for levels in iphone game. Basicly it's all about the location of obstacles in the rectangular world. The obstacles would be color-coded -- where the white pixel is, there's no obstacle. Black means there is one at this point.
Now I need to use this data to do 2 things: (a) display the level map, (b) for in-game calculations. So, in general, I need a way to read the data from the bitmap and create some data structure (matrix-like) with those information - to both overlay the bitmap onto the level graphics as well as to calculate collisions and such.
How should I do it? Is there any easy way to read the data from image? And what's the best format to keep the images for this?
Have you looked at how Texture2D translates an image file to an OpenGL Texture ?
Tip: take a look at this Method in Texture2D.m:
- (id) initWithCGImage:(CGImageRef)image orientation:(UIImageOrientation)orientation sizeToFit:(BOOL)sizeToFit pixelFormat:(Texture2DPixelFormat)pixelFormat filter:(GLenum) filter
In 3D apps, it's quite common to use this kind of representation for height maps, in a height map, you use a Texture with colors that range from black to white ( white represents the maximum altitude )
For example, from this:
To this:
That was just to tell you that your representation is not that crazy :).
About reading the bitmap, I would also recommend you to read this (just in case you want to go deeper)
Hope I helped a bit!