Effacer les filtres
Effacer les filtres

How to get a matrix which acquires a pixel values along a spiral trajectory of Image.

1 vue (au cours des 30 derniers jours)
Hi, I'm working on compressive sensing for laser scanning applications. I want to sample the image along a continuous trajectory and get the pixel values. I'm able to get the pixel values along a continuous trajectory. In this case, a spiral trajectory. However, I don't know how to obtain the sampling matric C in y = Cx, where x is the input vector image, C is the sampling matrix which, on multiplying, gives values along the defined trajectory and y is the pixel values along that trajectory.
clear all;
clc;
%% Goal is to acuqire a pixel values along a spiral trajectory of Image (X).
% i.e y = Cx;
% where y is a m*1 measument matrix
% C is a m*N sampling matrix
% X is a N by 1 vectorized Image.
% N = n1*n2 where n1, n2 are size of the image
% Paramters for Spiral
dSpirals = 30;
nSpirals = 20;
CompresRatio = 0.4;
InputImage = imread('barbara1.png');
[height width] = size(InputImage);
N = height*width;
m = round(CompresRatio*N);
nPoints = m;
theta = linspace(0,360*nSpirals, nPoints);
% Define Spiral
x = round(((width/2)+1) +(theta/dSpirals).*cosd(theta));
y = round(((height/2)+1) +(theta/dSpirals).*sind(theta));
plot(x,y);
axis([0 width 0 height]);
grid on;
%% Measure the pixel values along the spiral trajectory
Measure = zeros(m,1);
for i = 1:m
Measure(m) = InputImage(x(i),y(i));
end
%% How to find C in y = CX where:
% y = Measure
% X = InputImageV %i.e., InputImageV = InputImage(:);
  4 commentaires
Matt J
Matt J le 29 Juil 2022
Modifié(e) : Matt J le 29 Juil 2022
I don't see how you'd be able to solve for x, because C is non-square. If C were square and invertible, it would be a permutation matrix. You don't need the matrix form of C to solve an equation which is just a permutation.
In any case, if you are certain that C is what you want, you will hopefully consider Accept-clicking my answer below.
Ajay Gunalan
Ajay Gunalan le 1 Août 2022
Just as an optional comment, I'll add these. I was able to reconstruct the image (X) in spite of C being a non-square matrix. Click here for the result and code. The result is not perfect. However, I'm working on it to get the optimal result.

Connectez-vous pour commenter.

Réponse acceptée

Matt J
Matt J le 29 Juil 2022
sz=size(Image);
J=sub2ind(sz,x,y);
I=(1:numel(x))';
C=sparse(I,J,1);
  5 commentaires
Matt J
Matt J le 29 Juil 2022
This should fix it.
sz=size(Image);
J=sub2ind(sz,x,y);
I=(1:numel(x))';
C=sparse(I,J,1,numel(x), prod(sz));
Ajay Gunalan
Ajay Gunalan le 29 Juil 2022
Modifié(e) : Ajay Gunalan le 3 Août 2022
Thank you so much for solving it quickly. It solved my issue. I could have never solved this on my own. I still don't understand your solution. But it works. I will try to understand it. Once again, thanks a lot..!

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by