I want to color the result of a search - swift3

I want to color the result of a search

Use an NSAttributedString and give the words you want to color a foreground color attribute.

I hope this logic gets you well....
You can store all the text in and array of words separating them by the "space" and the use the compare function in swift and then perform task according to that so that you can change the colour of that particular word.
I hope this logic can be helpful. if you need any more clarification let me know cheers :)

Related

If I mask an SVG, how can I know if tha mask actually has something?

I have a project in which I need to recreate an SVG and animate it given some positions (x,y), and I am supposed to know which elements of the SVG are drawn in a certain position.
My first thought was to mask the elements of the SVG in the position I'm given. But how do I know if there's actually something in the mask? Because it could be empty right?
I have to do this using C++. Can anyone help me with this or suggest another idea?

Image bounding boxes from sprite sheet

I've a sprite sheet containing a set of icons as shown here:
I'd like to get the bounding box (at pixel precision) of all icons inside it, some cases like list, grid have to be considered as only one icons. Any ideas are more than welcome.
I think the main issue in your problem is that some icons contain disjoint parts.
If all the icons were in only one part, you could just find the "connected components" (groups of white pixels) in your image and isolate them.
I don't know your level in image processing but to connect the parts of one icons, I would probably use dilation, which is a morphological method to expand (under constraints) the areas of maximum intensity in an image.
If you need any clarification, please let me know !
In general, it is not possible: only the humans have enough context to determine which of the disjoint parts belong together. You can approximate it using various ways, but it's a lost cause - and IMHO completely unnecessary. Imagine writing a test for this functionality - it's impossible, it requires a human in the loop, since the results for any particular icon sheet don't generalize. Knowing that the algorithm works for some sheet tells you nothing about whether it will work for some other sheet that you know nothing about a-priori.
It'd be simpler to manually colorize each sprite to have a color different than that of its neighbors. Then a greedy algorithm could find the bounding boxes easily without having to approximate anything.

Extracting Stone from Image

Any thoughts on an algorithm to extract the stone from images like this?
stone http://www.highdesertlapidary.com/media/5/a2079181363c96d4d9c754_s.JPG
The stones are all different colors. I need to separate them from both the background and any rulers that might be present.
Thank you.
you could try this, http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/resources.html
and then choose a threshold what you desire, it is very good for grouping and segmentation, code is also publicly available.
It may be better if you place the stone on some other surface which is of a different color, may be placing a white sheet below would help(if that is possible)

Minimum distance between markers

Each red circle in this map is a point but due to the density of them, there isn't enough space to show the text labels for all of them. So I want to filter them down to just show those which can show a text label.
How can I do this? marker-spacing seemed to be promising but makes no difference. I see no "marker-min-distance" as there is with "text-min-distance".
Basically there's no point in showing a marker at all if it can't be identified with text. This is for a non-interactive offline map.
There is marker-spacing.
If you want to draw only labelled markers, use shields instead (answered here).

How to detect Text Area from image?

i want to detect text area from image as a preprocessing step for tesseract OCR engine, the engine works well when the input is text only but when the input image contains Nontext content it falls, so i want to detect only text content in image,any idea of how to do that will be helpful,thanks.
Take a look at this bounding box technique demonstrated with OpenCV code:
Input:
Eroded:
Result:
Well, I'm not well-experienced in image processing, but I hope I could help you with my theoretical approach.
In most cases, text is forming parallel, horisontal rows, where the space between rows will contail lots of background pixels. This could be utilized to solve this problem.
So... if you compose every pixel columns in the image, you'll get a 1 pixel wide image as output. When the input image contains text, the output will be very likely to a periodic pattern, where dark areas are followed by brighter areas repeatedly. These "groups" of darker pixels will indicate the position of the text content, while the brighter "groups" will indicate the gaps between the individual rows.
You'll probably find that the brighter areas will be much smaller that the others. Text is much more generic than any other picture element, so it should be easy to separate.
You have to implement a procedure to detect these periodic recurrences. Once the script can determine that the input picture has these characteristics, there's a high chance that it contains text. (However, this approach can't distinguish between actual text and simple horisontal stripes...)
For the next step, you must find a way to determine the borderies of the paragraphs, using the above mentioned method. I'm thinking about a pretty dummy algorithm, witch would divide the input image into smaller, narrow stripes (50-100 px), and it'd check these areas separately. Then, it would compare these results to build a map of the possible areas filled with text. This method wouldn't be so accurate, but it probably doesn't bother the OCR system.
And finally, you need to use the text-map to run the OCR on the desired locations only.
On the other side, this method would fail if the input text is rotated more than ~3-5 degrees. There's another backdraw, beacuse if you have only a few rows, then your pattern-search will be very unreliable. More rows, more accuracy...
Regards, G.
I am new to stackoverflow.com, but I wrote an answer to a question similar to this one which may be useful to any readers who share this question. Whether or not the question is actually a duplicate, since this one was first, I'll leave up to others. If I should copy and paste that answer here, let me know. I also found this question first on google rather than the one i answered so this may benefit more people with a link. Especially since it provides different ways of going about getting text areas. For me, when I looked up this question, it did not fit my problem case.
Detect text area in an image using python and opencv
In the Current time, the best way to detect the text is by using EAST (An Efficient and Accurate Scene Text Detector)
The EAST pipeline is capable of predicting words and lines of text at arbitrary orientations on 720p images, and furthermore, can run at 13 FPS, according to the authors.
EAST quick start tutorial can be found here
EAST paper can be found here