Is it possible to resize image without changing its total number of pixels?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Abdul Hannan Qureshi
le 19 Avr 2022
Commenté : Abdul Hannan Qureshi
le 19 Avr 2022
I want to reduce each pixel size upto 0.5 but I want the total number of pixels to be the same. Is this possible ?. Kindly Advise.
4 commentaires
Réponse acceptée
Image Analyst
le 19 Avr 2022
Modifié(e) : Image Analyst
le 19 Avr 2022
@Abdul Hannan Qureshi if you resize the image matrix variable, it will have a different number of elements, not the same.
You can display the tick marks in real world units, such as cm or m, if you use the 'XData' and 'YData' options for imshow().
However regionprops() always measures in pixels so to get from pixels into cm you'd have to multiply by a cmPerPixel scaling/calibration factor that you computer. The attached demo walks you through that process.
Plus de réponses (1)
DGM
le 19 Avr 2022
Modifié(e) : DGM
le 19 Avr 2022
Maybe something like:
A = imread('cameraman.tif');
[h w] = size(A); % [256 256]
imshow(A,'xdata',[1 w]/2,'ydata',[1 h]/2)
hold on
plot(64,64,'yo','linewidth',2) % just for demonstration
Note that while the image is still 256x256, the image is plotted on a half-size grid. The NW pixel is now at [0.5 0.5] instead of [1 1], and the center of the image is now at [64 64]. The same can be done with image()/imagesc(). I can't really demonstrate imdistline() in the forum editor, but you should be able to use it just fine.
Voir également
Catégories
En savoir plus sur Convert Image Type 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!