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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
vpmammana
Posts: 37
Joined: 2015-12-06T14:13:46-07:00
Authentication code: 1151

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

Post 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]
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
vpmammana
Posts: 37
Joined: 2015-12-06T14:13:46-07:00
Authentication code: 1151

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

Post by vpmammana »

I am using 6.7.7-10

I will update it...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

Please also provide your platform!
vpmammana
Posts: 37
Joined: 2015-12-06T14:13:46-07:00
Authentication code: 1151

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

Post by vpmammana »

ok. Sorry. I didn't realize the issue.

I will separate the images as follows:

here it goes:

Image
vpmammana
Posts: 37
Joined: 2015-12-06T14:13:46-07:00
Authentication code: 1151

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

Post by vpmammana »

I use Linux: Ubuntu 14.x

I guess apt-get will update it???
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
vpmammana
Posts: 37
Joined: 2015-12-06T14:13:46-07:00
Authentication code: 1151

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

Post by vpmammana »

Here goes the reference image:

Image
vpmammana
Posts: 37
Joined: 2015-12-06T14:13:46-07:00
Authentication code: 1151

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

Post 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!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
vpmammana
Posts: 37
Joined: 2015-12-06T14:13:46-07:00
Authentication code: 1151

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

Post 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.
vpmammana
Posts: 37
Joined: 2015-12-06T14:13:46-07:00
Authentication code: 1151

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

Post by vpmammana »

Man, this is great!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
vpmammana
Posts: 37
Joined: 2015-12-06T14:13:46-07:00
Authentication code: 1151

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

Post 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...
Post Reply