Skitch has this nice effect where it will draw its text on a white background. I'd like to emulate this effect. I found this article on Cocoabuilder where an example approach is given. It kind of works, but has some really sharp corners on the outline where Skitch has nice soft corners. Note how smooth the point of Skitch's 'S' is compared to my attempt using the "draw it twice" algorithm (Skitch on left, my attempt on the right).
Any ideas on what sort of approach to take to get those nice soft corners?
My first thought here would be to convert the glyphs to paths, and then stroke those paths behind. See CTFontCreatePathForGlyph and similar techniques for how this might work.
Related
The question is very simple. I just want to draw a simple circle around some part of an image with mouse. Not a fancy circle. It can be not at all a complete circle. I just want to circle around some part of an image to make it stand out inside the image.
As simple as this task is, I did not find any solution on google as it always proposes me very complex tasks like how to draw a circle and the like, which are not at all what I want. The problem is that Gimp is very powerful and so non-intuitive for very simple use cases. Any help will be appreciated as it will free me of doing all these changes under windows on another computer and sending the images via email and etc.
Quickest:
Make a circle selection with the Ellipse select tool (you can constrain it to a circle by depressing the Shift key after you start dragging).
Edit > Stroke selection (use preferably "Line" mode, that will also allow you to make a dotted line).
This said, to annotate images there are better alternatives.
I am trying to match the "teletext holidays" in the image below (with the white bits connecting all the letters:
I have achieved the following by going to the layers section, right-clicking the text layer, and select “Blending Options.” Then marking the checkbox next to “Stroke.”
Any hints or tips to point me in the correct direction would be appreciated. I appreciate moving the letters within the font closer together will help so will work on that now.
Any help appreciated.
Update:
Made the letters appear closer together. However, using stroke is making the black letters "shrink" in size so think a different solution is required. Thoughts?
With regard to that final image and the black letters appearing smaller. When applying the stroke, tick to indicate that it should be outside and not center or inside
And with helping to ensure that the white parts do meet.... Hmm... Well. Difficult to do the horiztonal stroke without it also applying vertically.
I would agree with others that Illustrator would be better but in Photoshop I might try to duplicate the text, make it all white, put it on the layer behind your main text and manually create a horizontal white pattern.
^ I really hope somebody has a better idea for that last bit though.
Alan,
I would like to help you with this issue. First of all your reference design is designed in adobe illustrator not in photoshop because there is some limitation in photoshop for the stroke feature.
So I would like to suggest you design it in adobe illustrator and not waste your valuable time in photoshop for your desired output.
If you need more help regarding it feel free to contact me at niravmistrydata#gmail.com.
Thank you,
Nirav Mistry
Starting with an arbitrary rectangle, a user can place any number of circles within.
The circles are allowed to overlap each other without restrictions.
The circles can be of different sizes.
What would be the best way to test if the rectangle is completely covered by the circles?
It seems a very tricky algorithm, but fortunately dsomebody thought about it before :)
Check this question:
https://cs.stackexchange.com/questions/11163/circles-covering-a-rectangular-how-to-verify-it
Seems to have the same problem as you.
I eventually found that the simplest solution (for me anyway) in both JS and Objective-C was to simply iterate of over each pixel and check for the colour (assuming circles are coloured) and check if it was the colour of a circle (or it's border). As soon as a colour from a circle was found then iteration stops as the area is obviously not fully covered by the shapes.
The advantage to this solution is that the actual shape doesn't matter (we ended up adding other shapes also).
We have a system where people are being taken a face shot via a DSLR camera. We need the people's images with transparent background. What we're currently doing is taking the image and editing and cropping it in Photoshop, removing the background image with the Magic Eraser tool.
What I am looking for is a way to parse the image and automatically erase the semi-white background we have, along with the resizing and cropping. Is there some kind of library or code sample that does this without requiring manual intervention?
This is a real complex problem. Like the answer below suggested you'll need to do a fuzzy match on each pixel and set it to be transparent but you also need to detected other nearby pixels to make sure they are not close in color. A white tag on the shirt, white eyelids, hair, pale skin reflecting the flash. All are candidates to be removed by any greedy fuzzy logic.
Think about the Magic Wand tool in Photoshop. How good is it at detecting the edges of the person in the picture? Yeah, and that's the top standard of image editing software with thousands of engineering hours behind it.
This is not a feasible request for a Q&A format, and this is one of those things that humans just do better than machine. BUT, that doesn't mean it's not possible, and who knows, you might be the one to do it. Just don't do it in VB.NET please :)
Some pseudo-code to get an idea of what you need to do:
Bitmap faceShot = Bitmap.FromFile(filepath)
foreach pixel in faceShot
//the following line is where the magic happens, you can do any fuzzy match on the color that suits you
//figure out your color range and do a fuzzy match percentage wise
if (pixel between RGB(255,255,255) and RGB(250,235,215)) //white and antique white
pixel.setAlpha=0
endif
end foreach
You could start with this as a starting point for processing a single image,
http://www.java2s.com/Code/VB/2D/ProcessanImageinvertPixel.htm
Basically, if you have a constant background color (like the TV green-screen), it's just a matter of selecting pixels close to the color you are erasing and setting their Alpha level to 0 (transparent). Treating the RGB values like XYZ coordinates, you can do a 3d distance from your background color, and make everything within a certain threshold transparent.
As an improvement, you could also make everything within another threshold semi-transparent so the edges right around hair and stuff like that look softer and less harsh.
Alternatively, you could probably do the same exact thing with good results in Photoshop, as it should support batch processing.
Edit, thinking about it some more, you may want to use a green screen type background as well instead of an off-white one like you stated, as you may make people's eyes transparent. I would definitely try to batch it in Photoshop/Gimp/etc.
I am drawing a path into a CGContext following a set of points collected from the user. There seems to be some random input jitter causing some of the line edges to look jagged. I think a slight feather would solve this problem. If I were using OpenGL ES I would simply apply a feather to the sprite I am stroking the path with; however, this project requires me to stay in Quartz/CoreGraphics and I can't seem to find a similar solution.
I have tried drawing 5 lines with each line slightly larger and more transparent to approximate a feather. This produces a bad result and slows performance noticeably.
This is the line drawing code:
CGContextMoveToPoint(UIGraphicsGetCurrentContext(),((int)lastPostionDrawing1.x), (((int)lastPostionDrawing1.y)));
CGContextAddCurveToPoint(UIGraphicsGetCurrentContext(), ctrl1_x, ctrl1_y, ctrl2_x, ctrl2_y, lastPostionDrawing2.x, lastPostionDrawing2.y;
[currentPath addCurveToPoint:CGPointMake(lastPostionDrawing2.x-((int)furthestLeft.x)+((int)penSize), lastPostionDrawing2.y controlPoint1:CGPointMake(ctrl1_x, ctrl1_y) controlPoint2:CGPointMake(ctrl2_x, ctrl2_y)];
I'm going to go ahead and assume that your CGContext still has anti-aliasing turned on, but if not, then that's the obvious first think to try, as #Davyd's comment suggests: CGContextSetShouldAntialias is the function of interest.
Assuming that's not the problem, and the line is being anti-aliased by the context, but you're still wanting something 'softer.' I can think of a couple of ways to do this that should hopefully be faster than stroking 5 times.
First, you can try getting the stroked path (i.e. a path that describes the outline of the stroke of the current path) using CGContextReplacePathWithStrokedPath you can then fill this path with a gradient (or whatever other fill technique gives the desired results.) This will work well for straight lines, but won't be straightforward for curved paths (since the gradient is filling the area of the stroked path, and will be either linear or radial.)
Another perhaps less obvious option, might be to abuse CG's shadow drawing for this purpose. The function you want to look up is: CGContextSetShadowWithColor Here's the method:
Save the GState: CGContextSaveGState
Get the bounding box of the original path
Copy the path, translating it away from itself by 2.0 * bbox.width using CGPathCreateCopyByTransformingPath (note: use the X direction only, that way you don't need to worry about flips in the context)
Clip the context to the original bbox using CGContextClipToRect
Set a shadow on the context with CGContextSetShadowWithColor:
Some minimal blur (Start with 0.5 and go from there. The blur parameter is non-linear, and IME it's sort of a guess and check operation)
An offset equal to -2.0 * bbox width, and 0.0 height, scaled to base space. (Note: these offsets are in base space. This will be maddening to figure out, but assuming you're not adding your own scale transforms, the scale factor will either be 1.0 or 2.0, so practically speaking, you'll be setting an offset.width of either -2.0*bbox.width or -4.0*bbox.width)
A color of your choosing.
Stroke the translated-away path.
Pop the GState CGContextRestoreGState
This should leave you with "just" the shadow, which you can hopefully tweak to achieve the results you want.
All that said, CG's shadow drawing performance is, IME, less than completely awesome, and less than completely deterministic. I would expect it to be faster than stroking the path 5 times with 5 different strokes, but not overwhelmingly so.
It'll come down to how much achieving this effect is worth to you.