Effacer les filtres
Effacer les filtres

Creating an image using row number, column number, and corresponding Intensity?

2 vues (au cours des 30 derniers jours)
Raju Kumar
Raju Kumar le 5 Juil 2022
Commenté : Jon le 5 Juil 2022
Hello Matlab experts,
I would like to create an image (pixel size 256x256) from a given data set which has three columns. Column 1 and 2 are basically different combination of row and column numbers (e.g. [r c] = [166 122], [166 123] etc.) and column 3 contains 'Intensity' corrposnding to each row number and column number. How do I create an image from such data given that there are 30000 data sets including repeatations?
Thanks a lot in advance for any leads.
Raju

Réponse acceptée

Jon
Jon le 5 Juil 2022
Modifié(e) : Jon le 5 Juil 2022
Suppose you have your data as you describe in matrix A, then you could use:
B = zeros(256,256); % preallocate array to hold image
idx = sub2ind(size(B),A(:,1),A(:,2)); % get linear, columnwise indices
B(idx) = A(:,3); % assign corresponding intensity values to form image matrix
  2 commentaires
Raju Kumar
Raju Kumar le 5 Juil 2022
Thanks a lot, Jon. It works.
Jon
Jon le 5 Juil 2022
Glad to hear. In case it is of interest here is a good article to help you learn more about linear indexing https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.html

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Interpolation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by