How to keep track of where each measurement originates from?

3 ビュー (過去 30 日間)
Goncalo Costa
Goncalo Costa 2021 年 7 月 14 日
回答済み: Prachi Kulkarni 2021 年 8 月 11 日
When creating a pattern/mask for single-pixel imaging of a picture, I use a different delta function for each measurement, and this is all done withing a for loop as follows:
img = double(im2gray(picture)) %grayscale of n pixel image , read here as picture
for i = 1:n^2
delta = zeros(n,n); %delta is nxn matrix where a single element is 1.
delta(i) = 1; % This element changes with each loop.
A = real(ifft2(delta)) %mask
B(i) = sum(img.*A, 'All'); %light coming through
end
How do I keep track of where each measurement comes from. ie, which delta function corresponds to a measurement [1].
The code is intended to be applied to the use of PCA to the data (which I am still uncertain as how to do) to decrease the number of measurements needed to analyse an image.
  2 件のコメント
Walter Roberson
Walter Roberson 2021 年 7 月 16 日
You do not use A after you compute it, but you use P?
Goncalo Costa
Goncalo Costa 2021 年 7 月 21 日
sorry that was a silly mistake when simplifying the code for the question

サインインしてコメントする。

回答 (1 件)

Prachi Kulkarni
Prachi Kulkarni 2021 年 8 月 11 日
Hi,
The index variable i itself is an indicator of which delta function corresponds to which measurement.
For example, for the 10th measurement B(10), the delta function can be regenerated whenever required as-
delta = zeros(n,n);
delta(10) = 1;
Alternatively, if you want to store all the delta functions (although it may not be memory-efficient), you can rewrite your code as-
img = double(im2gray(picture)); % grayscale of n pixel image , read here as picture
delta = zeros(n,n,n^2); % collection of all delta functions
for i = 1:n^2
deltaSingle = zeros(n,n); % delta is nxn matrix where a single element is 1.
deltaSingle(i) = 1; % this element changes with each loop
delta(:,:,i) = deltaSingle; % placing individual delta in the collection of delta functions
end
A = real(ifft2(delta)); % mask created for all delta functions simultaneously
B = squeeze(sum(img.*A, [1 2]))'; % light coming through computed for delta functions simultaneously

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by