Iphone App Color to black&White Image RGB Value - iphone

Currently i am working on Iphone app similar to http://itunes.apple.com/us/app/color-splash-free/id385504846?mt=8 in which we can make some or full portion of pic as black and white.
Please check the attach image for more detail.
I just want to know that how i can start it.I am familiar with paint app.Is this any rgb Value of any color or Its gray scale overlapping of an image with actual image at background or hide some portion of actual image and show grayscale image in that part.
Please share any code if you have that.
Thank you

Can't offer a concrete answer but a general approach from doing something similar.
What you have in 32 bit image is 4 channels of pixel information: red pixels, green pixels, blue pixels and alpha value for each pixel.
A gray image as you know from using any paint program is when all three colour components red, green and blue have equal intensity value.
E.g.
rgb value of (0.5,0.5,0.5) would be halfway between black and white.
What I can suggest is you looking into finding where the user tap the screen, take rectangular sample of pixels from the touch point into memory loop through all the sample pixels and set their red, green and blue value to be equal, then redraw the newly modified image onto the view again.
If you want to quickly convert an entire image to grayscale, you can use GPUImageFramework by Brad Larson? (apologies if I misspelled your name Brad :P).
You can use his GrayScaleFilter class to generate a grayscale image.

Related

Broken outline image in Unity

I want to put an outline around images but on some of the images the outline is broken. Notice the corners in the attached image.
I'm using 5 as the X and Y on the outline. In addition if I use a color besides black, the outline seems to be trying to blend. For example if I set the color to EEC209FF. See 2nd image.
So, i'm trying to explain both of your questions:
Why is the outline shape broken?
That’s the way the default Unity Outline script works: It just draws your UI.Image 4 time with the defined offset behind your image, it 4 different directions, which is cheap performance trick that fits most needs, but obviously not yours.
You can take a look at the Outline script on bitbucket here.
Why is the outline color partially yellow?
Unitys Outline Script draws your image in the background and multiplies the color values with your custom color.
That’s why the white part of your image on the upper right edge become yellow in the outline (almost the color you definied EEC209FF).
The outline on the lower right stays greens since it the take the colors from your image edge, approximately 19B754 multiplied with EEC209 to 178B03, which is a slightly dark green.

Create Mosaic on image

In image app i have to blur the selected areas of image. Something like create mosaic at selected area of image. i have to get each pixel color of selected area and then increase the size of each pixel. here is the reference link that i am using http://soulwithmobiletechnology.blogspot.in/2011/05/create-mosaic-with-your-image-part-1.html . But not able to implement this practically for selected area. Can any one have some sample for the same.
There are two solutions for this
1. Get the screen shot of the area where you want the mosaic effect and apply effect to the same portion. Then add the image(with mosaic effect) to the original image.
2.Get the pixel of the area you want to be effected and then gave effect to those pixels.*

Color overlaying algorithm

I'm looking for an algorithm to overlay a color on top of existing picture. Something similar to the following app (wall painter): http://itunes.apple.com/us/app/wall-painter/id396799182?mt=8
I want a similar functionality so I can paint walls in an existing picture and change them to a different color.
I can work both in yuv or rgb mode.
To successfully paint the walls in a picture, you have to do two steps:
Find the boundary of the wall within the picture (select the part of the image to be colored)
Apply the desired color to the selected area
The first step is the hard part. It similar to what Photoshop's magic wand tool would do. And indeed a search for magic wand algorithm turns up a few good articles such as this article with Objective-C code.
The second step is much easier and can be achieve with CGContextSetBlendMode and CGContextDrawImage.
You could try drawing into a graphics context with kCGBlendModeColor. From the documentation:
Uses the luminance values of the background with the hue and saturation values of the source image. This mode preserves the gray levels in the image. You can use this mode to color monochrome images or to tint color images.
Experimenting with other blend modes might also do the trick. See the documentation for details (search for "kCGBlendMode").
The RGB and YUV color models are not really great for changing colors in this way. I think the best color model for this is HLS.
Link: RGB to HLS and HLS to RGB conversion source code
H (hue) will change the base color
L (luminance) will change the brightness
S (saturation) will change the amount of color
You can evaluate the effect of these three components in a photo editing app, like Photoshop of The GIMP.

How to create an art asset that can be dynamically colored in software?

I asked this question on the Graphic Design site, but it includes a programming component that might be better answered here.
Specifically, I have a bunch of photographic crayon images. I would like to remove the color from one to produce a neutral image that I can load into an iPhone app that I'm writing and dynamically color. The crayon images have dark regions (shadows) and light regions (shine) which I would like to preserve. I will be dynamically coloring it with many different colors, ranging from white to rainbow colors to black.
My first inclination is to turn the image into a grayscale image and then somehow turn the color channel into an alpha channel, and change the color of all pixels to black. Then I could use it as a mask. However, this would only preserve the shadows, and I would lose all the highlights.
Any ideas?
Two options come to mind:
Make a grayscale version that could be tinted as you said, with the shadows and highlights simply white and gray.
Make an outline, i.e. an image with alpha that had 0% opacity in the colored parts, say 10% white over the highlights, 10% black on the shadows, and 100% black/dark gray for the lines/edges. The idea being that you could put any color under the outline and it would look right.

Convert an image to an iPhone toolbar icon

I have a grayscale icon that I'm editing with Photoshop with a transparent background, but I can't, for the life of me, figure out how to convert the icon to one that can be used as an iPhone toolbar icon. If I simply save the image as a PNG, it doesn't show up as anti-aliased on the iPhone because every pixel with color is being rendered as black, instead of a shade of gray.
According to the Apple docs and other sources, there needs to be an alpha channel on the image to specify varying levels of transparency for each pixel. However, I have no idea what that means. I've read these posts and docs from Adobe and I still can't figure out how to properly convert a grayscale image into one that can be used as an iPhone toolbar icon. The blog post is hard to comprehend and poorly written, and the Adobe docs don't really help.
http://cahit.hayalet.net/blog/514/converting-an-image-to-iphone-toolbar-icon/
http://livedocs.adobe.com/en_US/Photoshop/10.0/help.html?content=WS74B356C9-353F-4483-8632-7B1A102F2A2E.html
Can someone point me in the right direction or provide exact, step-by-step directions to doing this in Photoshop?
It's much more simple than having to muck with actual masks in Photoshop.
iPhone toolbar icons are about 30px by 30px, so make a new Photoshop file with those dimensions. Ensure the background is transparent (you can specify that when creating a new file).
Then, any pixels you draw on top of this transparency become what iOS uses for the icon. Doesn't matter what color it is in Photoshop for NSToolbar icons -- they're automatically used as masks by iOS.
Leave transparent the parts you want to show through. Save as 24-bit PNG, and chuck into XCode as usual.
For a few icons that serve as good starting examples, check out the ones I publish for free here: http://glyphish.com Just take one of the PNGs and open it in Photoshop and you'll see that it's drawn in an arbitrary color (#444444) with varying levels of opacity to create darker and lighter parts of the icon.
This is more of a photoshop question than coding but anyway, here's a suggestion.
Lunacore has a good tutorial on how to use masks.
What you want to do is:
Make sure you're background is transparent.
Create a new layer and
fill it with any solid color.
Create a mask on the solid color
layer, and fill your greyscale image into the mask. (Use your
greyscale image as the mask.)
Toolbar icons use your image as a mask. They only consider what transparancy the image has. Not what color or shade.