Page 2 of 2
Re: txt:- error
Posted: 2012-05-23T16:12:41-07:00
by VanGog
I test CGWin now but don't know how to paste text from console or to paste it there ...
fmw42 wrote:The time delay is writing all the pixels from binary to ascii text format with all the required information about coordinates and color. That is slow. Note time is a unix function. It will be even slower adding grep. But the main slowdown is converting to txt format.
time convert logo: logo:png
real 0m0.055s
user 0m0.026s
sys 0m0.015s
time convert logo: logo.txt
real 0m2.654s
user 0m2.477s
sys 0m0.034s
times for that image tmp3.png
http://i48.tinypic.com/14ajwjk.png
real 0.672s
user 0.015s
sys 0.031s
It really print all pixels, I did not realized that it prints black pixels. That is not the best way for me.
It takes cca 0.5 of seconds
but with the | grep white command:
real 0.813s
user 0.061s
sys 0.061s
What other method to use to get first white pixel?
Re: txt:- error
Posted: 2012-05-23T16:45:56-07:00
by fmw42
You never said before that you wanted
only the first white pixel. I may have missed that. But the fact is that converting to txt format is slow.
Using compare will be faster:
Try this:
# create image that definitely has some white in it.
convert rose: -threshold 90% -depth rose_t90.png
# now find first match with a 1x1 white pixel.
time compare -metric rmse -subimage-search rose_t90.png \( -size 1x1 xc:white \) null:
0 (0) @ 63,10
real 0m0.162s
user 0m0.133s
sys 0m0.014s
the line returned from the compare says in order: the rmse absolute graylevel difference of zero (perfect match), the normalize (0 to 1) rmse difference of zero (perfect match), @ means location, location of x=63,y=10.
see
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/
-metric AE may be a bit faster. you can test different metrics.
Re: txt:- error
Posted: 2012-05-23T19:39:08-07:00
by anthony
fmw42 wrote:The time delay is writing all the pixels from binary to ascii text format with all the required information about coordinates and color. That is slow. Note time is a unix function. It will be even slower adding grep. But the main slowdown is converting to txt format.
time convert logo: logo:png
real 0m0.055s
user 0m0.026s
sys 0m0.015s
time convert logo: logo.txt
real 0m2.654s
user 0m2.477s
sys 0m0.034s
One way to speed it up is to output the image using PPM or PGM. (Use
-compress none for text numbers instead of binary (similar to MIFF:)
http://www.imagemagick.org/Usage/formats/#pbmplus
However even in ascii, it is not line oriented (though some text manipulation can fix that) and does not include coordinates, so you need to determine that by the number (line) position.
What it has over txt: is that it does not lookup any color comment information, which is probably where a lot of the time is spent, by the txt: coder.
I suppose a setting can be added to turn of comment lines in txt: (similar to turning of the image comment in histogram:) whcih should speed it up some.
Re: txt:- error
Posted: 2012-05-24T01:23:53-07:00
by VanGog
fmw42 wrote:You never said before that you wanted only the first white pixel. I may have missed that.
The word "only" is so important? I gave example from which it can be clear:
VanGog wrote:
In CMD I use this command to get first pixel
Code: Select all
FOR /F "tokens=1 delims=" %%R IN ('convert "file2.bmp" -crop 300x100+340+400 -fuzz 5%% -fill black +opaque #660000 -fill white -opaque #660000 txt:- ^| grep white') DO (
echo %%R
break
pause
)
But it seems to me that it is very slow. The convert command goes through whole image even I need it to be stopped on first white pixel.
Re: txt:- error
Posted: 2012-05-24T10:57:26-07:00
by fmw42
But you have not tried my compare suggestion, which is faster and will give you just the first match.
Re: txt:- error
Posted: 2012-05-27T14:20:05-07:00
by VanGog
fmw42 wrote:
# create image that definitely has some white in it.
convert rose: -threshold 90% -depth rose_t90.png
I forgot to answer. I have uploaded incorrect inmage, not that one with white pixels.
Code: Select all
convert rose: -threshold 90%% -depth rose_t90.png
But
convert.exe: option requires an argument `-depth' @ error/convert.c/ConvertImage
Command/1192.
Re: txt:- error
Posted: 2012-05-27T14:22:29-07:00
by fmw42
Sorry, typo error
convert rose: -threshold 90%% -depth 8 rose_t90.png
Re: txt:- error
Posted: 2012-05-27T14:30:08-07:00
by VanGog
Time is linux command... I am too tired to test it now in CygWin, Later.
Please use code tag to emphasize the code, Thanks
Re: txt:- error
Posted: 2012-05-28T03:39:47-07:00
by VanGog
I cannot test the command time because it gives me error \r on end of line...
I am not satisfied with CygWin. GNUWin32 is better even it does not have bash shell and time command equivalent.
Re: txt:- error
Posted: 2012-05-28T20:16:57-07:00
by anthony
It because you used a windows text editor (like notepad) that adds the returns.
Remove them, or use a text editor that allows you to not add returns on end of lines. I use Notepad2 on windows.
ASIDE: IMv7 "magick" scripts will accept both newlines, returns, or return-newlines as end of line markers, and work accordingly. Though this is technically breaking (or adding to) the 'BASH' quote/escaping standard the "magick" script parser is generally following.
Re: txt:- error
Posted: 2012-05-29T06:29:48-07:00
by VanGog
great. I like scripting.
Re: txt:- error
Posted: 2012-05-31T12:48:18-07:00
by VanGog
anthony wrote:
ASIDE: IMv7 "magick" scripts will accept both newlines, returns, or return-newlines as end of line markers, and work accordingly. Though this is technically breaking (or adding to) the 'BASH' quote/escaping standard the "magick" script parser is generally following.
I also think, there is the need for IM scripts. Because many times during generating of image I looked for some simple way how to detect some information - either from the target file or from different file. Such classic like to do some effect but conditionally. E.g. if there is some color in some image on same coordinate, then do not draw pixels in that location (or do not do this effect at all)... Actually it is possible to do it with new layer from original image and with a mask and fill. But why so many steps for one simple job? So I hope it could be really substantial improvement.
Re: txt:- error
Posted: 2012-05-31T19:25:21-07:00
by anthony
The script will have 'functions' but 'if' and 'loop' constructs may not be so easy to add, still it will be looked at.
This does not me we can do away with shell wrappers. Such wrappers will still be needed, but their is a 'co-processing' technique that will be much more usable when you need a lot of 'condition and looping'.
that is The shell runs a single IM command in background, which will hold the images in memory and process them - without ever exiting. The shell can then sends operation to perform on those images, while recieving back requested information for decision making, and looping.
Shell provides the control, while IM provides the processing.
This (co-processing) should be possible NOW with the IMv7 "magick" command, though it is still in alpha. I just have not done any real examples of actually doing this as yet, and I am still working on things.
Re: txt:- error
Posted: 2012-06-01T01:29:02-07:00
by VanGog
I am thankful that you still continue developing and improving IM, and that it is not something closed.