
Issue while plotting image (wrong scale)
18 ビュー (過去 30 日間)
古いコメントを表示
Hello, I am getting inverted image, and when I am trying to invert it using (reverse) I got the the corrected image but the y axis scale also got inverted. Is this correct or is there a way to correct it. Please suggest possible solution, I am confused whether it is right or not for single valued decomposition.
I have attached the MATLAB script and the output image for your reference after inversion but the scale is also inverted and is going from high to low.
for i = 1:52;
data(:,:,i) = rgb2gray(imread(sprintf('~/Downloads/4_68_image/scene_%0.4d.bmp',i)));
end
r = 1024;
c = 1024;
data = double(reshape(data,r*c,52));
mode = 1
freq = 1
[Phi ,~, C]=svd(data-repmat(mean(data,2),[1 size(data,2)]),'econ');
% Plot the figures
close all
figure('name','POD')
subplot(1,1,1)
imagesc(reshape(Phi(1:r*c,mode),r,c));axis image;set(gca,'Ydir','reverse')

0 件のコメント
回答 (1 件)
Raag
2025 年 7 月 4 日 2:56
Hi Priyank,
This is a common issue when displaying reshaped image data in MATLAB. The confusion arises because MATLAB’s ‘imagesc’ function, by default, places the (1,1) pixel at the top-left, with the y-axis increasing downwards ('YDir','normal').
To keep the image upright and the y-axis increasing from top to bottom (the MATLAB default), you can flip the image data before displaying, and use 'YDir','normal'. Here’s how you can modify your code:
imagesc(flipud(reshape(Phi(1:r*c,mode), r, c)));
axis image;
colormap(jet); % Optional: for better visualization
colorbar; % Optional: show color scale
set(gca, 'YDir', 'normal'); % Standard y-axis direction (top-to-bottom)
Here ‘flipud()’ flips the image data vertically, correcting any inversion caused during reshaping.
'YDir','normal' ensures the y-axis increases from top to bottom, which is standard in MATLAB.
This is how the output may look like:

For more information, refer the following documentation:
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!