Ask Your Question

misha's profile - activity

2015-01-08 18:31:18 -0500 commented question Multidimensional DCT with OpenCV

I'm not sure, but I might be able to do that. Thank you for your suggestion.

2015-01-08 04:06:37 -0500 asked a question Multidimensional DCT with OpenCV

I have a 3D matrix (2 spatial dimensions, 1 temporal dimension). Its size is 32 x 32 x 64. I would like to calculate the 3D DCT of this matrix. The documentation hints that this may be possible:

DCT_ROWS performs a forward or inverse transform of every individual row of the input matrix. This flag enables you to transform multiple vectors simultaneously and can be used to decrease the overhead (which is sometimes several times larger than the processing itself) to perform 3D and higher-dimensional transforms and so forth.

But it doesn't go beyond that. How do I do a higher-dimensional DCT? I can think of a way of doing this by combining 1D DCTs (in one direction) and rotation (transposition?) of the 3D matrix, but I don't see an easy way to rotate the matrix. Can somebody point me in the right direction?

2013-04-29 03:22:44 -0500 received badge  Supporter (source)
2013-02-14 20:41:48 -0500 commented answer Comparing color histograms

Thank you for your suggestion. However, since I'm implementing a method from a paper, I need to use Chi-squared difference. Chi-squared difference should work here as well, as it has worked well in the past. What could be the problem?

2013-02-14 07:21:27 -0500 received badge  Organizer (source)
2013-02-14 07:19:53 -0500 asked a question Comparing color histograms

I'm using the following code to compare the color histograms of two images:

import cv
import sys    
im1 = cv.LoadImage(sys.argv[1])
im2 = cv.LoadImage(sys.argv[2])
assert cv.GetSize(im1) == cv.GetSize(im2)    
B_BINS, G_BINS, R_BINS = 4, 4, 4
hist_size = [ B_BINS, G_BINS, R_BINS ]
c_range = [ 0, 256 ]
ranges = [ c_range, c_range, c_range ]
hist1 = cv.CreateHist(hist_size, cv.CV_HIST_ARRAY, ranges, 1)
hist2 = cv.CreateHist(hist_size, cv.CV_HIST_ARRAY, ranges, 1)    
rchannel = cv.CreateImage(cv.GetSize(im1), im1.depth, 1)
gchannel = cv.CreateImage(cv.GetSize(im1), im1.depth, 1)
bchannel = cv.CreateImage(cv.GetSize(im1), im1.depth, 1)
planes = [ bchannel, gchannel, rchannel ]    
cv.Split(im1, bchannel, gchannel, rchannel, None)
cv.CalcHist(planes, hist1, 0, None)
cv.NormalizeHist(hist1, 1.0)    
cv.Split(im2, bchannel, gchannel, rchannel, None)
cv.CalcHist(planes, hist2, 0, None)
cv.NormalizeHist(hist2, 1.0)   
chisq = cv.CompareHist(hist1, hist2, cv.CV_COMP_CHISQR)
print chisq

The problem is I that sometimes the result is significantly greater than it should be. For example, given the following images frame-0010.png, frame-0011.png, frame-0012.png and frame-0013.png, respectively (continuous frames from a movie):





I get the following results:

misha@misha-lmd:~/git/cutter/poc$ python frame-0010.png frame-0011.png 
misha@misha-lmd:~/git/cutter/poc$ python frame-0011.png frame-0012.png 
misha@misha-lmd:~/git/cutter/poc$ python frame-0012.png frame-0013.png 

The last result is unexpectedly large. Since there are 64 bins in the histograms, and the histograms are normalized, their Chi-squared difference could not possibly be that high. Furthermore, the images are nearly identical, with the exception that they are getting progressively lighter. My expectation is that their histogram difference should be fairly low. What could be the problem here?

Also, I'd like to note that this is fairly stable code, so it has worked before (couple of months ago, at least).