-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Histogram Backprojection #979
Conversation
|
||
# Both images should be single or 3-channel | ||
assert len(shape1) == len(shape2),\ | ||
"both images should be 1-channel or 3-channel" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This check is actually asserting "Both images should have the same number of dimensions," not specifying 1 or 3. I recommend changing to shape1 == shape2
if both images must have equivalent shape, otherwise omitting this check and changing the API (see below).
Channels are generally stored in the third dimension when present, but often grayscale images omit the 'channels' dimension so it's difficult to distinguish automatically between a very small/thin image and one which is supposedly RGB. For example, a 2D image would usually be of shape (M, N)
, not (M, N, 1)
; in contrast an RGB image would usually be of shape (M, N, 3)
. Checking .shape[-1]
might work, but what if the image is grayscale and happens to have N == 3
? The check breaks down. Thus, we usually ask the user to tell us if an image is multichannel or not.
skimage.segmentation.slic
shows our current consensus API, I believe: a boolean multichannel=
kwarg switches between code paths.
Thank you for bringing this back @abidrahmank ! I left a couple minor comments about API/input checks because we've come to some consensus about this since the previous backprojection PR. Your error in Travis for Python3 is because the |
======================== | ||
|
||
Histogram Backprojection is a tool for image segmentation, object tracking | ||
etc. based on object's color distribution.. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two full stops
Clearly, I am confused as to what exactly histogram backprojection is, which is why we need a good explanation in the gallery! |
Its main use is segmentation based on the color properties of the object. Say, you know the color properties (color histogram) of a region (or small part of the region) you want to segment. You backproject it to the original image to segment out the full region. It is more like "Color Tool" in GIMP. (But honestly, I can demonstrate it, but don't know how to explain it. One more example here: http://opencvpython.blogspot.in/2013/03/histograms-4-back-projection.html) |
@JDWarner : regarding |
@abidrahmank Your description there is perfect! Here's a first attempt using my new-found understanding :) Histogram back-projection is a method for segmentation based on a marked region of the object of interest. The histogram properties of that region is computed, and used to identify parts of the image that correspond closely. |
Parameters | ||
---------- | ||
img1 : array | ||
Image array on which img2 is backprojected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Image containing the object to be segmented.
@stefanv : yeah... that is it :) |
---------- | ||
img1 : array | ||
Image array on which img2 is backprojected | ||
img2 : array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
object_image : (M, N, 3) ndarray
Image that represents the object. This can either be a slice from the object in the original image,
or the input image with all areas outside the object set to 0. [<-- can we make it work that way? Then
we support masks, which is cool.]
Minor update to that description to emphasize that we seek correspondence, not difference. |
"We are no longer using Vagrant for our backend, and as such we aren't maintaining the Vagrant images. We're looking into a way of doing this, but for now you can email us at support AT travis-ci.org and we can spin up a debug VM for you if you need to debug an issue." |
I'll go ahead and ping them. |
What is the status of this PR? |
I will try to finish this weekend.
|
This PR is continued in another branch, to take recent developments into account. |
Thank you @abidrahmank for the implementation. |
This is an implementation of Histogram Backprojection based on:
Swain, Michael J., and Dana H. Ballard. "Indexing via color histograms." Active Perception and Robot Vision. Springer Berlin Heidelberg, 1992. 261-273.
(This was submitted one year ago, reviewed and certified OK, but somehow I corrupted my git repo, so merging was not possible back then. So I am resending the same)