Ask Your Question

lalecarbon's profile - activity

2014-06-25 05:13:57 -0600 commented question Convert matlab image svd method to opencv
2014-06-23 05:42:54 -0600 answered a question Will OpenCV run on Windows 8.1 64 bit?

Hello dear AA9GG. you can use it. I've shown this job in my website: Opencv Good luck

2014-06-23 05:02:56 -0600 asked a question Convert matlab image svd method to opencv

Hello everyone,
I want to write a program with opencv by c++ in the visual studio. My code is following matlab code:

close all
clear all
clc

%reading and converting the image
inImage=imread('pic.jpg');
inImageD=double(inImage);

[U,S,V]=svd(inImageD);

% Using different number of singular values (diagonal of S) to compress and
% reconstruct the image
dispEr = [];
numSVals = [];
for N=5:25:300
  % store the singular values in a temporary var
  C = S;

  % discard the diagonal values not required for compression
  C(N+1:end,:)=0;
  C(:,N+1:end)=0;

  % Construct an Image using the selected singular values
   D=U*C*V';


  % display and compute error
  figure;
  buffer = sprintf('Image output using %d singular values', N)
  imshow(uint8(D));
  title(buffer);
  error=sum(sum((inImageD-D).^2));

  % store vals for display
  dispEr = [dispEr; error];
  numSVals = [numSVals; N];
end

What's your opinion to do this? I want to save image in a text file and retrieve it from file into the Mat array. I've written this part as follow:

Mat image;
FileStorage read_file("pic_file.txt", FileStorage::READ);
read_file["pic"] >> image;
read_file.release(); 
Mat P;
image.convertTo(P, CV_32FC3,1.0/255);
SVD svda(P); //or SVD::compute(P,W,U,V);

But I have problem with SVD function and it doesn't work. Is there anything to do for computing SVD compression of an image?


Thank You so much.
Vahids.

2014-06-22 11:30:58 -0600 received badge  Editor (source)
2014-06-22 11:05:52 -0600 asked a question apply SVD on image has error

Hi everyone. I've tried to compute SVD of an image by following code:

Mat image;
Mat U, W, V;
image = imread("pic.jpg");
Mat P;
//convert to float 64 for computing 
image.convertTo(P, CV_64FC1,1.0/255);
namedWindow("Display P window", WINDOW_AUTOSIZE);
imshow("Display P window", P);   
waitKey(0);
SVD svda(P);
//or SVD::compute(P, W, U, V);

program correctly executed and image has shown, but svd didn't compute. when I traced the code, I got following message at opencv svd function:

__vfptr = opencv_core248d.dll!0x00007ffed694ce50 (load symbols for additional information) {opencv_core248d.dll!0x00007ffed6602afe, ...}

My purpose is computing svd of an image and show image by change number of eigen values. Please help me. Thank you. Vahids