How to make image and assign 255 pixel value to specific values in MATLAB

6 vues (au cours des 30 derniers jours)
Stephen john
Stephen john le 24 Août 2022
Commenté : Aditya le 24 Août 2022
Hello every one , I hope you are doing well. I have the dataset attached and the following code gives the output.
The variable rows1 are the new indexes where pixel value of 255 should exist and crop the image based on that min and max value of this new indexes.
for example The rows1 has the first 51 values are 1417 then the 255 exist 51 times on 1417
How can i do it in MATLAB
% Find where image is 255
mask = grayImage == 255;
% Find indexes
[rows, columns] = find(mask);
% Find max row and column
maxRow = max(rows)
maxCol = max(columns)
maxOfEither = max([maxRow, maxCol]);
% Find mins
minRow = min(rows)
minCol = min(columns)
% Divide indexes by the max and multiply by 1000
rows1 = round(10000 * rows / maxRow) ;
columns1 = round(10000 * columns / maxRow) ;
  1 commentaire
Aditya le 24 Août 2022
Could you elaborate the issue ? Where exactly are you stuck ? It is not clear

Connectez-vous pour commenter.

Réponses (0)


En savoir plus sur Matrices and Arrays 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