-2

Possible Duplicate:
Calculating energy using MATLAB

Energy is defined as follows:

Enter image description here

I'm planning to do the following:

1- Slide a window with dimensions 4X4 on an image

2- For each window calculate the energy

3- Find the histogram

For sliding the window over an image, I know that we can use nlfilter, but this requires a fun. Will this function be the energy? How can I use this with nlfiler?

So, how do you think I can go with 1,2, and 3 in MATLAB?

Community
  • 1
  • 1
Simplicity
  • 47,404
  • 98
  • 256
  • 385
  • 1
    Hint for #1: square the image element-wise and filter with a `ones(4)` mask. – Eitan T Jan 30 '13 at 08:55
  • you just got the answer for #2 in your previous question... http://stackoverflow.com/questions/14599816/matlab-calculating-energy – bla Jan 30 '13 at 09:00
  • And #3 was answered too in a previous question of yours... http://stackoverflow.com/questions/14454338/matlab-8x8-window-and-finding-mean – bla Jan 30 '13 at 09:04

1 Answers1

1

Summing up all the answers you got from previous questions (some by me):

fun = @(x) sum(x(:).^2)/sum(x(:)).^2; 
en= nlfilter(img,[4 4],fun);
bins= 100 ; %# or whatever number of bins you want
hist(en(:),linspace(min(en(:)),max(en(:)),bins));
bla
  • 25,846
  • 10
  • 70
  • 101
  • Because of the way @Med-SWEng wanted the `energy` to be compatible with `graycoprops` (see my comment to the question). I've also used the slow `nlfilter` and not `conv2` because that's what he\she wanted... I should add the `conv2` just for showing how fast it'll be... – bla Jan 30 '13 at 09:16
  • yep, you also told him that already... – bla Jan 30 '13 at 09:28
  • Yeah. And I apologize for the tone. These fire-and-forget questions sometimes get me. I'll be removing my comments now. – Eitan T Jan 30 '13 at 10:39