Page 2 of 4

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-13T19:55:54-07:00
by fmw42
The threshold will be image dependent. You will have to try to figure out what is a good value for your images. Or try some of my scripts that do thresholding. See, trianglethresh, kmeansthresh, kapurthresh, otsuthresh and others.

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-13T20:04:30-07:00
by vpmammana
I just realized I lost resolution after transferring to Photobucket.

Since that image is a way too low resolution, below you will find a single row where you can see that the dog image is getting confused with the grass (the color of the dog seems to be similar to the grass).

[img]
http://i1039.photobucket.com/albums/a47 ... qjxyvt.jpg
[/img]

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-13T20:08:00-07:00
by fmw42
Please upload your two input images separately. It is too unreliable for me to crop them consistently. In the future, please always post separate images, if you expect others to work on them for you.

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-13T20:09:42-07:00
by vpmammana
I am using 6.7.7-10

I will update it...

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-13T20:13:40-07:00
by fmw42
Please also provide your platform!

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-13T20:22:00-07:00
by vpmammana
ok. Sorry. I didn't realize the issue.

I will separate the images as follows:

here it goes:

Image

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-13T20:22:38-07:00
by vpmammana
I use Linux: Ubuntu 14.x

I guess apt-get will update it???

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-13T20:33:21-07:00
by fmw42
Sorry, I am on a Mac and know little about installing on Linux.

You only posted one image. I was suggesting you post both input images at full resolution. I don't see any change in size of the image you posted, if you say you earlier posted a low resolution version. Perhaps your image hosting service limits the size. Perhaps try another such as dropbox.com, if you really have a higher resolution (larger) pair of images.

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-13T20:37:17-07:00
by vpmammana
Here goes the reference image:

Image

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-13T20:40:20-07:00
by vpmammana
This is the information provided by ImageMagick "identify":

a0.jpg JPEG 320x240 320x240+0+0 8-bit DirectClass 14.4KB 0.000u 0:00.000

transparent_dog.jpg JPEG 320x240 320x240+0+0 8-bit DirectClass 15.5KB 0.000u 0:00.000

So, both images are 320x240.

Thanks for your help!

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-13T21:20:45-07:00
by fmw42
You have several objects in that pair that have changed. You need to adjust the threshold and pick the area that limits you to those objects. Not quite as easy as with only one object that changes.

This seems to work for me:

Code: Select all

convert sample1.jpg sample2.jpg -compose difference -composite diff2.png
convert diff2.png -auto-level -threshold 12% diff2_t12.png
convert diff2_t12.png -define connected-components:verbose=true -connected-components 4 null:
convert diff2_t12.png -define connected-components:area-threshold=141 -connected-components 4 -auto-level changes.gif
Image

Each separate region in the thresholded diff image that remains is coded with a different grayscale so it can be identified later. You can threshold this image to create a binary mask (-threshold 0) and use the mask with input image that has the new objects to see what it has selected.

Code: Select all

convert sample2.jpg \( changes.gif -threshold 0 \) -alpha off -compose copy_opacity -composite color_changes.png
Image

Also I would suggest you start with non-compressed images, such as png rather than jpg. JPG is lossy and would contribute to the noise in your images.

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-14T15:32:18-07:00
by vpmammana
Wow! This is great.

I think I can later select the object by its shape.

Now the issue is the variations of contrast... Do you think ImageMagick has "image registration" capabilities?

This sounds as a powerful technique to keep the image steady, no mater the ilumination issues.

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-14T15:33:14-07:00
by vpmammana
Man, this is great!

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-14T17:18:28-07:00
by fmw42
I think I can later select the object by its shape.
Once you have found it once, you can track it by its centroid in the CCL stats. That way you can filter it by tracking the coordinates in subsequent image or using a combination of coordinates, area, color and/or bounding box.

Also you can threshold each object so that you only have one feature in the CCL color output, then run

Code: Select all

identify -verbose -moments ccl_color_output.gif
to get image moments to characterize its shape. see http://www.imagemagick.org/script/identify.php
Now the issue is the variations of contrast... Do you think ImageMagick has "image registration" capabilities?
Yes, in IM you can use compare to locate the shift in an image relative to a slightly larger image.

But I have a script, phasecorr, that will tell you the offset of two same sized images. But you need to run IM in HDRI mode and install the FFTW delegate library.

Also you might try running a mild blur or median filter on each image to reduce the noise and keep the objects more together as some have been broken into two or more parts.

Re: Using ImageMagick to identify a person walking over grass for a fixed camera in a sunny day

Posted: 2015-12-14T21:04:22-07:00
by vpmammana
I will study these ideas.

How likely will my software be able to raise a warning in case of detecting a human being?

How about applications for blind people? Do you invision the use of ImageMagick to help blind people? I am not talking about OCR techniques, which are very well known.

I am focused on detecting human image in a door bell camera, so the person inside the house is able to tell how many people is there in front of the door, etc...