5
$\begingroup$

Getting the DCT coefficient based on what I've read, is usually done through a matrix, usually 8x8 or 16x16 using these formulas:

$$B_{pq}=\alpha_p\alpha_q\sum_{m=0}^{M-1}\sum_{n=0}^{N-1}A_{mn}\cos\left(\frac{\pi(2m+1)p}{2M}\right)\cos\left(\frac{\pi(2n+1)q}{2N}\right),\quad \begin{align} &0\leq p\leq M-1\\ &0\leq q\leq N-1 \end{align} $$

$$\alpha_p=\left\{ \begin{array}{ll} 1/\sqrt{M},& p=0\\ \sqrt{2/M}, & 1\leq p\leq M-1 \end{array}\right. \quad \alpha_q=\left\{ \begin{array}{ll} 1/\sqrt{N},& q=0\\ \sqrt{2/N}, & 1\leq q\leq N-1 \end{array}\right. $$

However, I would like to know if it is possible to determine the corresponding DCT coefficient of a pixel or of the edges of an image? Is there a way to detect edges through DCT coefficients?

$\endgroup$

migrated from stackoverflow.com Jan 18 '12 at 14:26

This question came from our site for professional and enthusiast programmers.

  • 3
    $\begingroup$ I'm not sure what you're asking. Are you looking for a way to associate a single pixel with a set of DCT coefficients? That's not really possible in any useful way. The DCT is a transform that maps an $N$-dimensional signal into an equally-sized $N$-dimensional signal. So, if you want an 8-by-8 matrix of DCT coefficients, you need an 8-by-8 matrix of pixel values to generate them. $\endgroup$ – Jason R Jan 18 '12 at 14:50
  • $\begingroup$ What I'm planning to do is to apply edge detection to obtain the locations/indices of the pixels and then get their corresponding DCT Coefficient. $\endgroup$ – Frank Smith Jan 18 '12 at 21:25
  • 2
    $\begingroup$ What I was trying to tell you with my previous comment is that there isn't a one-to-one mapping between a pixel and a DCT coefficient. An 8-by-8 DCT matrix, for example, is a function of each of the pixels in the 8-by-8 block that it was generated from. $\endgroup$ – Jason R Jan 18 '12 at 21:44
7
$\begingroup$

What I'm planning to do is to apply edge detection to obtain the locations/indices of the pixels and then get their corresponding DCT Coefficient

As others stated in the comment - any pixel in the given block is related to all co-efficient in the block and vice-versa.

However, understand that Edge detection is a process of finding the gradient. Linear convolution essentially does the job. What you can do is to apply equivalent of that convolution in the DCT domain which will give you an idea about the edge orientation in the DCT block domain.

While, this is relatively narrow area - there are papers which allows you to find edges in DCT blocks. See the references below:

  1. A Compressed Domain Scheme for Classifying Block Edge Patterns by Hyun Sung Chang, and Kyeongok Kang IEEE TRANSACTIONS ON IMAGE PROCESSING, VOL. 14, NO. 2, FEBRUARY 2005 145

  2. Direct feature extraction from compressed images by Bo Shen et. al. SPIE vol. 2670, Storage & Retrieval for Image and Video Databases IV, 1996

$\endgroup$
4
$\begingroup$

One can get the presence of an edge in a given DCT block. It is easier to compute the First order and second order moments from the given DCT coefficients. Variance in a small region is an approximation of the gradient at the center (x0,y0) of the block. The Variance in a block can be estimated from the DCT coefficients as summation of squares of the AC coefficients. It might not be possible to know the exact coordinates in the block containing the edge.

$\endgroup$
  • $\begingroup$ Thanks pv. Can you explain a bit more about finding first and second order moments from the dct coefficients? This seems like a very useful technique. $\endgroup$ – user391339 Feb 11 '15 at 18:43
3
$\begingroup$

Perhaps you can detect the presence of a sharp change in color/brightness by detecting high frequency components in the Y block. If there are non-zero coefficients in the high frequency end of the DCT block, that indicates a sharp edge. You won't know its exact position in the block without doing the transform, but you can know if there is a sharp line/dot.

$\endgroup$
2
$\begingroup$

you can´t. As you can see from the formula you posted, each DCT coefficient is a function of all the pixels in the block you are considering. Same holds for edges: if you extract the edges from an image, and then apply DCT using 8x8 blocks, each DCT coefficient depends on the value of the 64 pixels in the block

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.