필터 지우기
필터 지우기

How to find energy of an image

조회 수: 2 (최근 30일)
Dhrubajyoti Das
Dhrubajyoti Das 2014년 5월 9일
댓글: Image Analyst 2016년 1월 9일
I want to find the energy of an image using the formula given in the attached image. Please help.
  댓글 수: 4
Walter Roberson
Walter Roberson 2016년 1월 9일
You do not show the error message.
What is xpy?
size() is going to return p and q as scalars, but in your for loop you are using p as a vector. Your "for j" loop also does not refer to j at all, so there is no point in using a loop there if the code is correct.
Image Analyst
Image Analyst 2016년 1월 9일
If "i have a doubt not related to this question" then you should start your own question so we don't bug Dhrubajyoti Das with emails about updates to his question. In that question, I will answer with how you used the size function incorrectly.

댓글을 달려면 로그인하십시오.

답변 (1개)

Image Analyst
Image Analyst 2014년 5월 9일
Assuming F is the Fourier Transform, try fft2().
  댓글 수: 2
Dhrubajyoti Das
Dhrubajyoti Das 2014년 5월 9일
but sir, how to find the value of 't' as shown in the attached image.
Image Analyst
Image Analyst 2014년 5월 9일
F = fft2(grayImage) -- did you try it? Did you try anything like the code below:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures if you have the Image Processing Toolbox.
clear; % Erase all existing variables. Or clearvars if you want.
workspace; % Make sure the workspace panel is showing.
format long g;
format compact;
fontSize = 24;
%===============================================================================
% Read in a standard MATLAB gray scale demo image.
folder = fileparts(which('cameraman.tif')); % Determine where demo folder is (works with all versions).
baseFileName = 'cameraman.tif';
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
% Check if file exists.
if ~exist(fullFileName, 'file')
% File doesn't exist -- didn't find it there. Check the search path for it.
fullFileNameOnSearchPath = baseFileName; % No path this time.
if ~exist(fullFileNameOnSearchPath, 'file')
% Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
grayImage = imread(fullFileName);
% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[rows, columns, numberOfColorBands] = size(grayImage);
if numberOfColorBands > 1
% It's not really gray scale like we expected - it's color.
% Convert it to gray scale by taking only the green channel.
grayImage = grayImage(:, :, 2); % Take green channel.
end
% Display the original gray scale image.
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 1 1]);
% Give a name to the title bar.
set(gcf, 'Name', 'Demo by ImageAnalyst', 'NumberTitle', 'Off')
% Take the Fourier Transform.
F = fft2(grayImage);
realF = log(real(F));
% Display the original gray scale image.
subplot(2, 2, 2);
imshow(realF, []);
title('Original Grayscale Image', 'FontSize', fontSize);
% Sum up the values.
magImage = abs(F).^2;
energy = sum(magImage(:))

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Explore and Edit Images with Image Viewer App에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by