How to add clear looking / thin text in Paintshop Pro X6 - image-processing

I'm trying to add text to an image in PSP X6 and I know how to do it but how can I make it look clearer/thinner?
I've created this using Arial (9 pixels) and the default stroke width (1) and not sure what else to do to make the text look less thick...

As a long-time fellow user of Corel's PaintShop Pro (including several versions by JASC before that), I have experienced the "Text" tool fluctuate (in effectiveness) over the years. This can be quite frustrating - as the quality (crispness in particular) of the text seems to vary from version-to-version.. - and sadly X6 (recently superseded by X7) is no exception.
In answer to your question, I would recommend one of the following solutions:
To get the best result with small text:
1) Ensure that the "Anti-alias" option is set to either "Sharp" or "Off".
2) Double-check that the text is not set to Bold (obvious, I know - but easily missed)
3) If possible, try dark greys (rather than pure black) as this can sometimes seem "softer" around the edges.
If you have already checked and/or tried the above, then another option is to use the technique I have adopted many times over the years - as follows:
1) Create your text (e.g. "Previous") but in a separate document - and purposefully set the text size MUCH larger than you need (e.g. 100 Point - the bigger, the better).
2) "Flatten" that image (ensuring you preserve transparency if you plan to overlay your text on a background other than pure white).
3) Resize the image down to the approximate width you require (e.g. 100 Pixels wide) by using the "Image Resize" option and ensuring that "Resample Using" is ticked/checked - and that "Smart Size" is the option used (the others: Bicubic, Bilinear and Weighted Average can also sometimes deliver better results - a little trial and error might be the order of the day until you get the hang of the technique).
Providing the desired end size is not too small, you should find the end results MUCH better than simple typing in at (say..) 9 Point to begin with.
Worth noting that this technique works particularly well for "mid-size" text - but you should also see an improvement for smaller sizes too. So something of a workaround for sure, but it definitely can and does work.

Related

Fitting more systems on the first page of a Lilypond score

I'm working to improve upon an excellent sheet I found of Debussy's Deuxième Arabesque on the freely available Mutopia Project.
In particular, I'm interested in fitting the music on fewer pages but I struggle to have the first page display five systems instead of four with the version I arrived at.
From the reproduction above, I would like the fith system (starting at bar 13) to be at the bottom of the first page. It seems there are a lot of wasted space on the first page and I'm rather confident it will fit perfectly.
I have a hard time playing figuring out how to achieve this. I have displayed the spacing annotations as advised by the documentation but I do not seem to be able to make sense of it.
If I were typesetting this today, I would try changing the staff size, like this:
#(set-global-staff-size 18)
You can add the following to your paper block
\paper {
min-systems-per-page = #5
system-system-spacing.padding = #2 %fit staves closer together
system-system-spacing.stretchability = #15 %how flexible the spacing is
}
This will of course force that all other pages have at least five systems. You can play around with the padding and stretchability values and see what works best. Also, you might want to make the staves smaller than the default 20pt. To do that, you can add the following at the beginning of the file:
#(set-global-staff-size 18)

How to count red blood cells/circles in Octave 3.8.2

I have an image with a group of cells and I need to count them. I did a similar exercise using bwlabel, however this one is a bit more challenging because there are some little cells that I don't want to count. In addition, some cells are on top of each other. I've seem some MATLAB examples online but they all involved functions that aren't available. Do you have any ideas how to separate the overlapping cells?
Here's the image:
To make it clearer: Please help me count the number of red blood cells (which have a circular shape) like so:
The image is in grayscale but I think you can distinguish which ones are red blood cells. They have a distinctive biconcave shape... Everything else doesn't matter. But to be more specific here is an image with all the things that I want to ignore/discard/not count highlighted in red.
The main issue is the overlapping of cells.
The following is an ImageJ macro to do this (which is free software too). I would recommend you use ImageJ (or Fiji), to explore this type of stuff. Then, if you really need it, you can write an Octave program to do it.
run ("8-bit");
setAutoThreshold ("Default");
setOption ("BlackBackground", false);
run ("Convert to Mask");
run ("Fill Holes");
run ("Watershed");
run ("Analyze Particles...", "size=100-Infinity exclude clear add");
This approach gives this result:
And it is point and click equivalent as:
Image > Type > 8-bit
Image > Adjust > Threshold
select "Default" and untick "dark background" on the threshold dialogue. Then click "Apply".
Process > Binary > Fill holes
Process > Binary > Watershed
Analyze > Analyze particles...
7 Set "100-Infinity" as range of valid particle size on the "Analyze particles" dialogue
On ImageJ, if you have a bianry image, watershed actually performs the distance transform, and then the watershed.
Octave has all the functions above except watershed (I plan on implementing it soon).
If you can't use ImageJ for your problem (why not? It can run in headless mode too), then an alternative is to get the area of each object, and if too high, then assume it's multiple cells. It kinda of depends on your question and if can generate a value for average cell size (and error).
Another alternative is to measure the roundness of each object identified. Cells that overlap will be less round, you can identify them that way.
It depends on how much error are you willing to accept on your program output.
This is only to help with "noise" but why not continue using bwlabel and try using bwareaopen to get rid of small objects? It seems the cells are pretty large, just set some size threshold to get rid of small objects http://www.mathworks.com/matlabcentral/answers/46398-removing-objects-which-have-area-greater-and-lesser-than-some-threshold-areas-and-extracting-only-th
As for overlapping cells, maybe setting an upperbound for the size of a single cell. so when you have two cells overlapping, it will classify this as "greater than one cell" or something like that. so it at least acknowledges the shape, but can't determine exactly how many cells are there

Efficiently Computing Text Widths

I need to compute the width of a column with many rows (column AutoSize feature). Using Canvas.TextWidth is far too slow.
Current solution: My current solution uses a text measurer class that builds a lookup table for a fixed alphabet once and then computes the width of a given string very fast by adding up character widths retrieved from the lookup table. For characters not contained in the lookup table, the average character width is used (also computed once).
Problem: This works well for European languages but not for Asian languages.
Question: What's the best way to tackle this problem? How can such an AutoSize feature be realized without the relatively slow Canvas functions and without depending on a specific alphabet?
Thanks for any help.
You said you want to get the maximum text width for a column. Can't you, say, take only the 4 or 5 longest strings and get their widths? That way you won't have to find the width for all items and can save quite some time.
Or you use your cache to find the rough length of the strings and then refine that by getting the actual width for the top 4 or 5 items you found.
I don't think it matters a lot whether you use Canvas.TextWidth or GetTextExtentPoint32. Just use one of these to get the exact widths, after you used one of the methods above to guesstimate the longest/widest strings.
To those who think this doesn't work
If the poster of the original question thinks it could work, I have no reason to think it won't. He knows best what kind of strings can be in the columns he has.
But that is not my main argument. He already wrote that he does a preliminary textwidth by adding the predetermined individual widths of the characters. That does not take into account any kerning. Well, kerning can only make a string narrower, so it still makes sense to check only the top 4 or 5 items for the exact width. The biggest problem that can occur is that the column could be a few pixels too wide, no more. But it will be a lot faster than using TextWidth or GetTextExtentPoint32 or similar functions on each entry (assuming more than 5 entries), and that is what the original poster wanted. I suggest that those who don't believe me simply try it out.
As for using the pure string length: even that is probably good enough. Yes, 'WWW' is probably wider than '!!!!!', but the original poster will probably know best wat kind of string material he has, and if it is feasible. '!!!!!' or 'WWW' are not the usual entries one expects. Especially if you consider that not only one single string is checked, but the longest 4 or 5 strings (or whatever number turns out to be optimal). It is very unlikely that the widest string is not among them. But the original poster can tell if that is possible or feasible. He seems to think it is.
So stop the downvoting and try it out for yourself.
I'm afraid you have to use Canvas.TextWidth, or your implementation will be imprecise. The width of text depends on the font kerning, where different character sequences may have different widths (not just the total of individual character widths).
Me, I cut out the middle-man and use the Windows API directly. Specifically, I use GetTextExtentPoint32 with the .Handle of the Canvas. There's nothing you can do to be faster, other than caching results in some way, and frankly you'll just add overhead.

How to fully justify texts programmatically (Delphi)?

How can I fully justify a block of text (like MS Word does, not only on the right and not only on the left but on both sides)?
I want to justify some texts (mainly arabic text) adjusted to certain screen size (some handheld device screen actually, and its text viewer doesn't have this function) and save this text as justified. So I can reload and reuse it again elsewhere.
(The problem with MS word is, that if you copy the justified text from MS Word and paste it to another editor it'll copy it un-justified).
Update : for now I'm thinking of doing it like this:
get-a-word
get-word-width
add-word-to-total-Word and add-Word-width-to-total-word-width
check if total-Word-width = myscreen-width then continue
else if total-Word-width is between myscree-wdith and (myscreen-width -3) then
add-spaces-To-total-word until it = myscreen-width
This is what I'm thinking now, but I put this question up and hope to see if there is a better solution, or somebody else already implemented it.
PS: I hope I have made my question clear and I'm sorry for bad expression if there is.
edit1 : changed the title to make it more clear.
If you want to justify plain text, you can only add extra spaces to the lines to get them align on the left and right. Unfortunately the character widths differ in fonts; so doing it this way will only work for a certain font, unless you limit yourself to monospaced fonts where all characters have the same size.
If you want a result like in Word, adding spaces won't cut it. Word will not add spaces, but stretch and shrink the existing spaces. This information is lost when you copy and paste it into another app.
Either way, justifying is an optimization problem. If you are interested in a good solution and its implementation: have a look a TeX. For an implementation that works on plain text with monospaced fonts have a look at par
There are some API calls that may help:
ExtTextOut and GetCharacterPlacement
Look at the GCP_JUSTIFY flag for GetCharacterPlacement
ExtTextOut is used by Canvas.TextRect
The problem you are going to face is always going to be differences in the rendering of the font. Word handles full justification by adjusting kerning as well as adjusting the number of pixels between words by a few (either way). The end result is lined up both margins. This pixel adjustment is done BOTH ways, and as evenly as possible.
To properly handle this in your portable device you will have to also perform the same algorithm for the display of the text there.
If this is not possible, then the ONLY way you can even get somewhat close would be to add whitespace between words.
As has been pointed out in other answers Word does full justification by stretching the existing spaces often by very small amounts. This is only possible if you have full control over how your text is drawn on the screen (which word - or any other windows program has).
You only real option in this regard would be to implement your own text viewer on the platform you are targeting. Eg you would need to draw the text on the screen yourself (any platform that allows games should allow you to draw on the screen). However this seems like an awful lot of trouble to get justified text.
Sorry couldn't be of more help.

vertical edge setting

What column setting do you use in the IDE for the vertical edge. I use 80 columns in line mode, but I wanted to know if this is common or is there a more common standard? I have seen other options like background mode, but found it too distracting.
Vertical Edge, for those who are unfamiliar, is a line or an area which marks off the section where the code can be written. Anything beyond may not format the best way in other code readers or makes code readability tougher. Please correct if my understanding is inaccurate.
Widescreen monitors and a preference for a smaller font so I get more vertical lines makes 80 a little lacking on the wide side.
I don't have a vertical column setting. Any coding lines (usually ifs) that may be too wide, I split at logical operators. For text lines, its a bit more nebulous where I actually split them but split them conservative.
Note: Your question appears to be the same as: https://stackoverflow.com/questions/903754/do-you-still-limit-line-length-in-code and question 746853 (which I can't hyperlink to as I am a "new user")

Resources