2015-12-11 08:36:24 -0600
| commented question | FFT at 3D Mat how to create SparseMat??? |
2015-12-11 08:32:32 -0600
| commented question | FFT at 3D Mat well M(rows)=256, N(cols)=320, T(number of frames"liste.size()")=2310 |
2015-12-11 07:50:37 -0600
| commented question | FFT at 3D Mat I definite my matrix like that and that change from sequence to other cv::Mat output(rows*cols,liste.size(),CV_8UC3);
|
2015-12-11 03:54:08 -0600
| commented question | FFT at 3D Mat I get the best idea to express may self and I try to compute the Fourier transform with respect to the time coordinate.
I try to reshape my 3D cube into a 2D matrix, where the vertical coordinate is the pixel index (in the range [0, MN-1]) and the horizontal coordinate the time (range [0, T-1]), i.e. each row contains the values of one pixel in the sequence.and then apply the DFT routine along each row with the cv::dft() function and the flag CV_DFT_ROWS.in which, M x N is the size of each frame and T is the total number of frames .
but the code didn't run I suupose because of big size of mat output.
How can I resolve this thdrksdfthmn??? |
2015-12-10 08:15:30 -0600
| commented question | FFT at 3D Mat YES thdrksdfthmn IT's probably near to my goal to applicate FFT on vector of size N (number of frame) at each (x,y) is changing in time but how in c++. |
2015-12-10 03:45:47 -0600
| commented question | FFT at 3D Mat I read a lot fo tutorials but they always show how to compute FFT at 1 image "mat" i didn't find FFT of 3D and what about FFT means I have Idea |
2015-12-10 03:07:19 -0600
| asked a question | FFT at 3D Mat Hello,
I want to computing FFT at 3D matin C++: I have n images that I want to calculate FFT at z axe for each pixel(x,y),
and as a result the n images of amplitude and phase...
but I have no idea how to make that please help me.
cv::Mat phase;
cv::Mat magI;
cv::Mat I;
cv::Mat padded;
cv::Mat output;
cv::Mat ampIm;
I = imread(liste[0].toStdString().c_str(), CV_LOAD_IMAGE_GRAYSCALE);
int rows=I.rows;
int cols=I.cols;
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
for(int k=0;k<liste.size();k++)
{
I = imread(liste[k].toStdString().c_str(), CV_LOAD_IMAGE_GRAYSCALE);
Vec3b color = I.at<Vec3b>(Point(i,j));
output.at<Vec3b>(Point(j+i*(rows-1),k))=color;
}
}
}
int m = cv::getOptimalDFTSize(output.rows );
int n = getOptimalDFTSize( output.cols ); // on the border add zero values
cv::copyMakeBorder(output, padded, 0, m - output.rows, 0, n - output.cols, BORDER_CONSTANT, Scalar::all(0));
cv::Mat planes[] = {Mat_<float>(padded), Mat::zeros(padded.size(), CV_32F)};
cv::Mat complexI;
merge(planes, 2, complexI); // Add to the expanded another plane with zeros
dft(complexI, complexI,cv::DFT_ROWS|cv::DFT_COMPLEX_OUTPUT); // this way the result may fit in the source matrix
split(complexI, planes); // planes[0] = Re(DFT(I), planes[1] = Im(DFT(I))
cv::cartToPolar (planes[0],planes[1],magI,phase,true);
magI += Scalar::all(1); // switch to logarithmic scale
log(magI, magI);
for(int k=0;k<liste.size();k++){
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
Vec3b colorF =magI.at<Vec3b>(Point(j+i*(rows-1),k));
ampIm.at<Vec3b>(Point(i,j))=colorF;
}
}
//save ampIm;
}
|
2015-12-10 02:48:35 -0600
| received badge | ● Enthusiast
|
2015-12-08 04:56:42 -0600
| asked a question | extract values from planes[0] of FFT application Hello,
I want to rearrange values from planes[0] after computing FFT in image in order to display amplitude image but how to browser it.
Thanks. Mat magI;
cv::Mat phase;
img->load(liste[0]);
*img = img->scaled(widget.imageLabel->width(), widget.imageLabel->height(),Qt::IgnoreAspectRatio,Qt::FastTransformation);
QPixmap pixmap=QPixmap(QPixmap::fromImage(*img));
int rows=pixmap.width();
int cols=pixmap.height();
cv::vector<int> pixels;
for(int i=0;i<rows;i++){
for(int j=0;j<cols;j++){
for(int k=0;k<liste.size();k++)
{
cv::Mat I = imread(liste[k].toStdString().c_str(), CV_LOAD_IMAGE_GRAYSCALE);
int fftp = I.at<uchar>(j,i);
pixels[k]=fftp; }
cv::Mat ff;
cv::dft(pixels, ff, cv::DFT_ROWS|cv::DFT_COMPLEX_OUTPUT);
cv::Mat planes[] = {cv::Mat::zeros(pixels.size(),1, CV_32F), cv::Mat::zeros(pixels.size(),1, CV_32F)};
cv::split(ff, planes);
magnitude(planes[0], planes[1], planes[0]);
int m = planes[0].cols;
for(int l=0;l<m;l++)
{
magI.at<uchar>(j,i) = planes[0].0;//ERROR Iwant to put the first value of planes[0] in the first point in the image HOW
}
}
}
|
2015-12-08 03:19:27 -0600
| commented answer | computing FFT at a pixel in image with opencv |
2015-12-07 08:32:59 -0600
| asked a question | computing FFT at a pixel in image with opencv hello, I want to applicate FFT at one pixel in image at get the complex composants with opencv.
please help me.
Thanks. |
2015-12-04 03:25:25 -0600
| commented question | opencv and FFT |
2015-12-04 03:24:57 -0600
| commented question | opencv and FFT well, this code display FFT amplitude and phase image but it didn't applicate FFT in all image's pixels it applicate like I said before at each pixel in the time pixel 1 of image1, pixel1 in image2..., pixel1 in image n and then pixel 2 in image1, pixel 2 in image2..., pixel 2 in image n...
extract amplitude equation and phase from them and rearrange pixel in their images and display them.
I hope this time my problem is clear to you ... and Thanks a lot. |
2015-12-03 09:57:42 -0600
| received badge | ● Editor
(source)
|
2015-12-03 09:56:32 -0600
| asked a question | FFT and Opencv function fft_img = get_FFT()
%Compute the FFT phase or Amplitude CtrlFigHdl = GetFigHdl('CtrlFig');
ToggleButtonAmpHdl = findobj(CtrlFigHdl, 'Tag', 'ToggleButtonAmp');
ToggleButtonPhaseHdl = findobj(CtrlFigHdl, 'Tag', 'ToggleButtonPhase'); % detect if we want a Phase or Amplitude
if get(ToggleButtonAmpHdl, 'Value')
BufferType = 1; % FFT Amplitude type
elseif get(ToggleButtonPhaseHdl, 'Value')
BufferType = 2; % FFT Phase type
else
fft_img = [];
return;
end CtrlFigUsrDat = get(CtrlFigHdl, 'UserData'); % Do we need to update the FFT?
if (BufferType == CtrlFigUsrDat.Current.BufferType) && ~isempty(CtrlFigUsrDat.Current.Buffer)
% No we don't
fft_img = CtrlFigUsrDat.Current.Buffer;
else
% we need to compute a new fft
% Notes: fft(uint16) is double; fft(single) is single; fft(double) is double clear CtrlFigUsrDat; % Avoid duplication of data
CtrlFigUsrDat = ClearBuffer('main'); % makes room
% Get the ROI limits
[ROI_min_x ROI_max_x ROI_min_y ROI_max_y] = getROIlimits();
try
h = [];
% pre-allocation. We make it single as it's half the data needed and still good enough.
% The FFT computation below is converted in single as it is done, plane by plane
fft_img = zeros(ROI_max_y-ROI_min_y+1, ROI_max_x-ROI_min_x+1, CtrlFigUsrDat.Current.z_dim, 'single');
sizeOfSingle = 4;
h = waitbar(0,[num2str(size(fft_img,2)) ' * ' num2str(size(fft_img,1)) ' pixels * ', ...
num2str(size(fft_img,3)) ' frames * single (32 bpp) = ' num2str(numel(fft_img)*sizeOfSingle/(1024*1024),'%.2f'), ' MB'], ...
'Name', 'Computing FFT...', 'WindowStyle', 'modal');
set(h, 'HandleVisibility', 'off'); % do not integrate this into the line above
pause(0.1); % allow refresh
if BufferType == 1 % Amplitude
for i = ROI_min_x:ROI_max_x % along x
fft_img( : , i-ROI_min_x+1 , :) = abs(fft(single(get_RawData('ROI',i,':')),[],3));
if ishandle(h)
waitbar((i-ROI_min_x+1)/(ROI_max_x-ROI_min_x+1), h);
else
error('FFT aborted.');
end
end
else % Phase
for i = ROI_min_x:ROI_max_x % along x
fft_img( : , i-ROI_min_x+1 , :) = -angle(fft(single(get_RawData('ROI',i,':')),[],3));
if ishandle(h)
waitbar((i-ROI_min_x+1)/(ROI_max_x-ROI_min_x+1), h);
else
error('FFT aborted.');
end
end
end
% Update Buffer
CtrlFigUsrDat.Current.BufferType = BufferType;
CtrlFigUsrDat.Current.Buffer = fft_img;
setF(CtrlFigHdl, 'UserData', CtrlFigUsrDat);
catch FFTError
messageBox(FFTError.message, 1, 'FFT Error');
fft_img = []; % means it failed computing the FFT
end
if ishandle(h)
delete(h)
end
end |
2015-12-03 09:30:34 -0600
| commented question | opencv and FFT |
2015-12-03 07:32:44 -0600
| received badge | ● Student
(source)
|
2015-12-03 04:57:25 -0600
| commented question | opencv and FFT well ,I try to expess my self better, in fact I have n images and I want to applicate FFT in order to dispaly magnitude and phase images but itsn't like mentioned in the tutorial image by image I want to applicate FFT in the time at pixel1 in im1 at 1t then pixel1 in im2 at t2 then at pixel 1 in im3 at t3...
is it clear???
please help me if you can. |
2015-12-03 04:39:36 -0600
| commented question | opencv and FFT my problem here it's not how to extract magnitude or phase but how to applicate FFT on 3D image sequence of images???? |
2015-12-03 02:56:04 -0600
| commented question | opencv and FFT ok but even with the tutorial it explains how to display FFT magnitude from one image however my application is to how display FFT magnitude and phase from many images, i explain more I should appliacte FFT for the same pixel of all images (like FFT signal) it means FFT for pixel 1.1 from im1 to imFinal and FFF for pixel 1.2 from im1 to imFinal...
can you help me please. |
2015-11-26 03:41:50 -0600
| commented question | opencv and FFT |
2015-11-24 02:57:48 -0600
| commented question | opencv and FFT and what about the phase image I want just the phase please. |
2015-11-23 09:22:54 -0600
| commented question | opencv and FFT yes I found this tutorial, so this image displayed can be considered as amplitude and phase image in the same time??? |
2015-11-23 05:09:06 -0600
| asked a question | opencv and FFT function fft_img = get_FFT() % ****************************************************************************************************************************
% Compute the FFT phase or Amplitude
CtrlFigHdl = GetFigHdl('CtrlFig');
ToggleButtonAmpHdl = findobj(CtrlFigHdl, 'Tag', 'ToggleButtonAmp');
ToggleButtonPhaseHdl = findobj(CtrlFigHdl, 'Tag', 'ToggleButtonPhase');
% detect if we want a Phase or Amplitude
if get(ToggleButtonAmpHdl, 'Value')
BufferType = 1; % FFT Amplitude type
elseif get(ToggleButtonPhaseHdl, 'Value')
BufferType = 2; % FFT Phase type
else
fft_img = [];
return;
end
CtrlFigUsrDat = get(CtrlFigHdl, 'UserData');
% Do we need to update the FFT?
if (BufferType == CtrlFigUsrDat.Current.BufferType) && ~isempty(CtrlFigUsrDat.Current.Buffer)
% No we don't
fft_img = CtrlFigUsrDat.Current.Buffer;
else
% we need to compute a new fft
% Notes: fft(uint16) is double; fft(single) is single; fft(double) is double
clear CtrlFigUsrDat; % Avoid duplication of data
CtrlFigUsrDat = ClearBuffer('main'); % makes room
% Get the ROI limits
[ROI_min_x ROI_max_x ROI_min_y ROI_max_y] = getROIlimits();
try
h = [];
% pre-allocation. We make it single as it's half the data needed and still good enough.
% The FFT computation below is converted in single as it is done, plane by plane
fft_img = zeros(ROI_max_y-ROI_min_y+1, ROI_max_x-ROI_min_x+1, CtrlFigUsrDat.Current.z_dim, 'single');
sizeOfSingle = 4;
h = waitbar(0,[num2str(size(fft_img,2)) ' * ' num2str(size(fft_img,1)) ' pixels * ', ...
num2str(size(fft_img,3)) ' frames * single (32 bpp) = ' num2str(numel(fft_img)*sizeOfSingle/(1024*1024),'%.2f'), ' MB'], ...
'Name', 'Computing FFT...', 'WindowStyle', 'modal');
set(h, 'HandleVisibility', 'off'); % do not integrate this into the line above
pause(0.1); % allow refresh
if BufferType == 1 % Amplitude
for i = ROI_min_x:ROI_max_x % along x
fft_img( : , i-ROI_min_x+1 , :) = abs(fft(single(get_RawData('ROI',i,':')),[],3));
if ishandle(h)
waitbar((i-ROI_min_x+1)/(ROI_max_x-ROI_min_x+1), h);
else
error('FFT aborted.');
end
end
else % Phase
for i = ROI_min_x:ROI_max_x % along x
fft_img( : , i-ROI_min_x+1 , :) = -angle(fft(single(get_RawData('ROI',i,':')),[],3));
if ishandle(h)
waitbar((i-ROI_min_x+1)/(ROI_max_x-ROI_min_x+1), h);
else
error('FFT aborted.');
end
end
end
% Update Buffer
CtrlFigUsrDat.Current.BufferType = BufferType;
CtrlFigUsrDat.Current.Buffer = fft_img;
setF(CtrlFigHdl, 'UserData', CtrlFigUsrDat);
catch FFTError
messageBox(FFTError.message, 1, 'FFT Error');
fft_img = []; % means it failed computing the FFT
end
if ishandle(h)
delete(h)
end
end
|