create intersection points of paths on edge of mask. Adobe illustrator - path

The "A" in the following image is a compound path.
The lines are paths with a white stroke.
The A is a clipping mask that is clipping the white strokes.
I want to create anchor points for each path at the edge of the clipping mask.
This is what I want to Achieve:
I did this three years ago and can't remember how I did it. It's driving me crazy...

It can be done via Erase mode of the Shape Builder tool:
select all objects (the "A" must be a simple object, not a clipping mask)
select Shape Builder Tool (Shift M) and pressing Alt erase outers and internals unnecessary parts of lines.

Related

Detect digits rectangle then crop using ImageMagick or CoreImage in iOS

I'm developing an OCR app that reads the digits and copy them to clipboard automatically instead of manually typing...
I'm using (TesseractOCR) ... But before recognizing and in the image manipulating I'm improving the image for better recognition.
I used ImageMagick library and the filtered image looks like this :
But the Output of recognition is :
446929231986789 //The first and last numbers (4 & 9) were added
So I Want to detect only the white box to crop ...
I know that OpenCV do the trick but unfortunately it's C++ library and I don't speak that language :(
And I knew that iOS8 has a new CIDetector of type Rectangles but I don't want to neglect the previous versions of iOS
MY IMAGEMAGICK Filter CODE :
//Starting
MagickWandGenesis();
magick_wand = NewMagickWand();
//Reading the image....
NSString *tempFilePath = //Path of image
// Monochrome image
MagickQuantizeImage(magick_wand,2,GRAYColorspace,1,MagickFalse,MagickFalse);
// Write to temporary file
MagickWriteImage(magick_wand,
[tempFilePath cStringUsingEncoding:NSASCIIStringEncoding]
);
DestroyMagickWand(magick_wand);//Free up memory
// Load UIImage from temporary file
UIImage *imgObj = [UIImage imageWithContentsOfFile:tempFilePath];
// Display on device
Many thanks ..
I would go with simple pixel search. Since you want to crop the white area with digits all you need to do is to find left, right, top and bottom borders of the rectangle. Provided that rectangle is axis aligned and has enough white space around digits you should find first row or column that has continuous number of white pixels. For example to find left border (which I guess would be around 78th column) start searching from column 0 and go right. For each column count continuous white pixels (single for-loop from top to bottom). By continuous I mean series that is not interrupted by black one. If count will reach, say, 80% of height you have your left border. Do the rest accordingly starting from right side, top or bottom and move in the opposite direction. I guess there are some fancy procedures to detect the rectangle but your input has quite distinguishable characteristics. So instead of linking to some lib I suggest DIY. To speed things up you could increase your row by 2 or more. Or you could scale your image down, treshold it do 2 colors.
There is also one more way to do this. Flood-fill with white starting from one of the corners.

Xcode, iOS - Image line/shape recognition

I want to identify squares/rectangles inside my UIImageView (or UIImage).
I looked at "Very simple image recognition on iOS", but that's not quite what I'm looking.
At the moment I have an UIImageView which is given a UIImage from time to time.
Most of the UIImagees has black squares/rectangles like this:
.
But the corners may (or may not) have rounded edges.
How can I identify the first black square/rectangle's size?
The end result would be to resize my UIImageView to make the first black square in the UIImage fill the screen. Like so:
If your images will always be sharp black squares in a horizontal row, you could use corner detection to identify the rectangles, then pick out the four leftmost corners. I have three variants of corner detectors in my open source GPUImage framework based on the Harris, Noble, and Shi-Tomasi corner detection methods.
Running a GPUImageHarrisCornerDetectionFilter against your boxes with a threshold of 0.4 and sensitivity of 4.0 yields the following result:
They're a little hard to see, but red crosshairs mark where the detector found the corners of your boxes. Again, you just need to take the leftmost four points to find your target rectangle, and then simply scale your image or view so that this rectangle now fills your view.
An example of how to run such feature detection can be found in either the FilterShowcase or FeatureExtractionTest example within my framework. I describe the process by which I do this in this answer over at Signal Processing.
It seems easiest solution would be:
sum up all pixels vertically to the top-most row (like an excel table)
rows with the smallest/biggest value are your "gap" region
width can be derived from (2).
From what I understood about your question, you need to implement the Canny Edge Detection Algorithm for detecting the edges of the black borders in your image.
For this you should use the image processing framework available at the following links
Google
Github
Use the ImageWrapper *Image::cannyEdgeExtract(float tlow, float thigh)function from the Image.m file.

Placing an image in a specific region of another image

Here is an oval, and a box
The goal is to place the oval inside the green box.
If you imagine the green box on the bottom to be your bounds, the top image can be placed anywhere inside the green box. The oval cannot flow outside of the green box.
Input is just the two images and I'm told to "put the red oval in the green box." If it is not possible (eg: the oval is too big), nothing happens.
It is trivial to do it by hand in a image editor: just drag the top image over the green box and make sure it doesn't flow out the sides.
How should this problem be approached?
There are a variety of ways of doing this and choosing one depends on problem constraints. In the simplest case, if you know the exact colours of the red, blue, and green, and know that none of the shapes are rotated the solution is simple. First binarize the image so that only one object is separated (oval or rectangle) then find the highest,lowest,leftmost,and rightmost point for that object. Repeat for the other object. That information will tell you if the ellipse can fit in the rectangle.
If those constraints are too rigid, then you will probably want to use blob detection. Perhaps cvblob or cvblobslib. They can handle the much more general case of varying colours and orientations.

how to create a little arrow in a rectangle

I am trying to create a little arrow in the middle of one of the sides of a rectangle. ( like twitter tweet button).
Any ideas how to do it in fireworks cs4 ?
Thanks.
There are two ways of doing this and unlike all the answers presented here, they are going to give you more freedom if you want to resize your shape and yes the triangle will be a part of your final shape not a superimposed two shapes.
Extending a shape with Pen tool
First, start with a rectangle. It can have rounded corner, however you like it. Then, you can either ungroup it or selecting the subselection tool (the white arrow in the tools panel) and clicking on one of the corners, you can make it editable for the Pen tool. Then, choosing the Pen tool, click three times on the left side of the rectangle, creating three points apart from each other along the edge. Back to subselection tool and select the middle one. Clicking a few times on the left arrow key on your keyboard will make it go to left. Since we are altering the base shape, your new shape can receive further filters, stroke colors etc.
Adding your shape to another shape
Create your rectangle and triangle shape anyway you want to see it. Position triangle so the right of it is just over the left edge of the rectangle. Give it 1-2 px of intersection area if you want, you'll most likely play with this approach to have best results. Both objects selected, go to Modify menu and select Union under Combine Paths. This option will merge both shapes. Since, FW is going to approximate both object styles, you can a blurred stroke if you already had strokes in your objects. You can adjust it but some people thing the method described above is better since they are editing the original image so it's more constructive than guessing the outcome of this merging operation. As usual, using the Pen tool, you can refine your shape.
Have fun.
This question really doesn't belong on Stack Overflow, but I'll answer anyway, since I'm not sure where it should go.
If this is what you mean:
then try this:
Create a small triangle.
Rotate the triangle 90 degrees to the left, so that it looks like the arrow.
Position the triangle on the side of the rectangle.
Change the triangle's color to the same color as the rectangle.

Drawing a non rectangular part of a picture in delphi canvas

Can anyone share a sample code to draw a non-rectangular part of a picture in delphi canvas?
You're looking for GDI paths. Start here, which explains what paths are in this context, and provides links on the left to explain the functionality available with them.
Google can turn up lots of examples of using paths in Delphi. If you can't find them, post a comment back here and I'll see what I can turn up for you.
Your question is pretty vague. But I suspect what you are looking for is clipping regions. Read up on them. Set the clipping region on the target device to the shape you want, and then draw the image onto the device. Only the part of the image that would be within the clipping region will be drawn.
Canvas.Ellipse(0, 0, 10, 20); // not a rectangle
I use so called runlists for this feature (generalized shapes and blitting them). I've seen them called warplists too. A shape is encoded as a runlist by defining it as a set of horizontal lines, and each line is two integer values (skip n pixels,copy n pixels).
This means you can draw entire lines, leaving you with only "height" draw operations.
So a rectangle is defined (the first "skip" pixels from top level corner to the left corner (xorg,yorg). The rectangle is width_rect wide, and width_pixels goes a line further. width_pixels can be wider than the width of the picture (alignment bytes)
(yorg*width_pixels+xorg , width_rect),
(width_pixels-width_rect , width_rect),
(width_pixels-width_rect , width_rect),
(width_pixels-width_rect , width_rect),
..
..
This way you can make your drawing routines pretty generic, and for simple, regular shapes (rects, circles) it takes only minor math to precalculate these lists. It simplified my shape handling enormously.
However I draw directly to bitmaps, not to canvasses, so I can't help with that part. A primitive that efficiently draws a row, and a way to extract a row from a graphic should be enough.

Resources