Search found 30 matches

by tmelorc
2017-04-26T15:01:25-07:00
Forum: Users
Topic: Understanding centroid
Replies: 16
Views: 16899

Re: Understanding centroid

So I think now we can close this discussion. Thanks for all efforts.
Regards.
by tmelorc
2017-04-26T13:19:11-07:00
Forum: Users
Topic: Understanding centroid
Replies: 16
Views: 16899

Re: Understanding centroid

Yes, I agree. The execution time with IM on my HD image was

Code: Select all

real	0m0.764s
user	0m0.766s
sys	0m0.020s
But I think that I discover what is the problem with my OpenCV example. It is extracting a contour from the image to compute its centroid, not the whole component.
by tmelorc
2017-04-26T10:38:37-07:00
Forum: Users
Topic: Understanding centroid
Replies: 16
Views: 16899

Re: Understanding centroid


I used awk to do the computations:

convert pNcFvOf.png txt: | tail +2 | grep "gray(255)" | tr -cs "0-9\n" " " |\
awk ' { tot = NR; xsum += $1; ysum += $2; } END { print xsum/tot, ysum/tot } '


Thanks for this suggestion. It is nice for small images. But in my case, I have HD images and this ...
by tmelorc
2017-04-26T06:50:14-07:00
Forum: Users
Topic: Understanding centroid
Replies: 16
Views: 16899

Re: Understanding centroid

Now it is clear for horizontal regions. I checked by hand with the images
convert -size 100x200 xc:black -fill white -draw "rectangle 0,0 79,2" foo.png
convert -size 100x200 xc:black -fill white -draw "rectangle 0,0 79,0" foo.png
and I got the same result as from IM.

Now I have to check for L ...
by tmelorc
2017-04-26T06:32:17-07:00
Forum: Users
Topic: Understanding centroid
Replies: 16
Views: 16899

Re: Understanding centroid


I get your same values with IM 6.9.8.3 Q16 and IM 7.0.5.4 Q16.


Thanks for your effort.

I decided to use a very simple L-shaped image to be able to compute by hand and compare. But maybe I'm misunderstanding some computations.

If I'm not wrong the top left corner of image has coordinate (0,0 ...
by tmelorc
2017-04-25T20:34:22-07:00
Forum: Users
Topic: Understanding centroid
Replies: 16
Views: 16899

Re: Understanding centroid


Please always provide your IM version and platform when asking questions.

If you post your original image without the arrow and circle, I can double check the values


The original image:
http://i.imgur.com/pNcFvOf.png

My OS: Linux Mint 18 with
Version: ImageMagick 7.0.4-2 Q16 x86_64 2017-01 ...
by tmelorc
2017-04-25T20:27:06-07:00
Forum: Users
Topic: Understanding centroid
Replies: 16
Views: 16899

Re: Understanding centroid


For any given region (white or black), the centroid is just the average location of all pixels in the region. See https://en.wikipedia.org/wiki/Centroid

The difference may be due to the 4-connected option vs the 8-connected option.

Try

convert foo.png -define connected-components:verbose=true ...
by tmelorc
2017-04-25T19:33:18-07:00
Forum: Users
Topic: Understanding centroid
Replies: 16
Views: 16899

Understanding centroid

I am trying to understand how IM computes centroid of a binary image.

Consider this simple binary image created with
convert -size 100x200 xc:black -fill white -draw "rectangle 0,0 79,49" -draw "rectangle 0,50 19,99" foo.png


From IM connect components we get
convert foo.png -define connected ...
by tmelorc
2017-03-18T16:31:30-07:00
Forum: Users
Topic: Histogram of a (possible) binary image
Replies: 6
Views: 6458

Re: Histogram of a (possible) binary image

fmw42 wrote: 2017-03-18T16:13:45-07:00

Code: Select all

convert ZpEm88c.jpg -depth 8 -define histogram:unique-colors=true -format %c histogram:info:
Oh, thanks. Now using ong and -depth 8 I got exactly

Code: Select all

(255,255,255)
by tmelorc
2017-03-18T16:01:21-07:00
Forum: Users
Topic: Histogram of a (possible) binary image
Replies: 6
Views: 6458

Re: Histogram of a (possible) binary image

OK. I converted jpg to png first. Then, I tried exactly the same codes as above, using png everytime. I got the following histogram:

Code: Select all

   1015144: (    0,    0,    0) #000000000000 gray(0)
   2962856: (65535,65535,65535) #FFFFFFFFFFFF gray(255)
What is the meaning of 65535 instead of 255?
by tmelorc
2017-03-18T13:43:26-07:00
Forum: Users
Topic: Histogram of a (possible) binary image
Replies: 6
Views: 6458

Re: Histogram of a (possible) binary image


You save the images as JPEG. But that is a lossy format. That means pixel values (colours) are changed. If you save as JPEG, the file will contains colours that you didn't put there.

JPEG is a useful format for showing photos on the web. It should not be used for image processing.


So, what do ...
by tmelorc
2017-03-18T12:22:12-07:00
Forum: Users
Topic: Histogram of a (possible) binary image
Replies: 6
Views: 6458

Histogram of a (possible) binary image

Version: ImageMagick 7.0.4-2 Q16 x86_64 2017-01-02

Consider the file input.jpg . I applied some tools to obtain a kind of binary image .
convert input.jpg -threshold 62% -morphology smooth Octagon bin-input.jpg
convert bin-input.jpg -define connected-components:area-threshold=60000 -define ...
by tmelorc
2017-01-05T03:12:33-07:00
Forum: Users
Topic: Offsets in geometry (from tutorial)
Replies: 7
Views: 7447

Re: Offsets in geometry (from tutorial)

fmw42 wrote:Did you try using

Code: Select all

magick convert ...
The same problem.

Thanks for helping and discussion but I'm only following the topic, since I have no deep knowledge to help to fix the possible bug/feature.

Regards.
by tmelorc
2017-01-04T17:43:12-07:00
Forum: Users
Topic: Offsets in geometry (from tutorial)
Replies: 7
Views: 7447

Re: Offsets in geometry (from tutorial)

snibgo wrote:This may be a bug.

Try inserting "+region" after the negate.
No progress.
by tmelorc
2017-01-04T17:34:37-07:00
Forum: Users
Topic: Offsets in geometry (from tutorial)
Replies: 7
Views: 7447

Offsets in geometry (from tutorial)

Version: ImageMagick 7.0.4-2 Q16 x86_64 2017-01-02 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP
Delegates (built-in): bzlib freetype jng jpeg lzma png x zlib


I'm trying to learn ...