How to display subplot with multiple image with its own x and y axes ?
34 ビュー (過去 30 日間)
古いコメントを表示
I use subplot to display multiple images ,but it does not show axis for each image in the subplot.How to show it? Here is the code.Hope someone can guide.Thank you.
%create blank image
w = 150;
h = 150;
blankImage= 255*ones(w,h,3,'uint8');
%position of the letter in the empty cell
position_x = (w+1)/2;
position_y = (h+1)/2;
% varying the font size, start from 10 to 16
font_start = 58;
font_end = 64;
num_fontsA = font_start:2:font_end;
% get the number of fonts
numImagesA = length(num_fontsA)
% create a cell array with number of fonts to fill in the image in next step
A = cell(1, numImagesA);
% for loop to create letter 'A'
% grayscale
% store into the cell array
for i=1:numImagesA
for font_size = num_fontsA(i)
img= insertText(blankImage,[position_x position_y],'A','Font','Times New Roman','FontSize',font_size,'TextColor','black','BoxColor','w','BoxOpacity',0,'AnchorPoint','Center');
grayImage= rgb2gray(img);
BWImage = ~grayImage;
background = BWImage == 0;
foreground = ~background;
Newforegnd = foreground;
% figure('Name','Background and Object');
% montage({Newforegnd, background});
% Apply noise on the image
% Apply noise on the alphabet, using 0.01 standard deviation
Newforegndafter = imnoise(img, 'gaussian',0, 0.01);
%Apply noise on the background, using 0.01 standard deviation
backgroundafter = imnoise(img, 'gaussian',0, 0.01);
% imshowpair(background,backgroundafter,'montage');
title("Foreground before and after adding noise");
subplot(2,2,1);
imshow(Newforegnd);
subplot(2,2,2);
imshow(Newforegndafter);
subplot(2,2,3);
title(" background before and after adding noise");
imshow(background);
subplot(2,2,4);
imshow(backgroundafter);
0 件のコメント
採用された回答
ANKUR KUMAR
2021 年 7 月 11 日
編集済み: ANKUR KUMAR
2021 年 7 月 11 日
You need to make xaxis visible in every subplots. Here are the lines which you need to modify.
title("Foreground before and after adding noise");
subplot(2,2,1);
imshow(Newforegnd); h1 = gca; h1.Visible = 'On';
subplot(2,2,2);
imshow(Newforegndafter); h2 = gca; h2.Visible = 'On';
subplot(2,2,3);
title(" background before and after adding noise");
imshow(background); h3 = gca; h3.Visible = 'On';
subplot(2,2,4);
imshow(backgroundafter); h4 = gca; h4.Visible = 'On';
2 件のコメント
その他の回答 (1 件)
Sulaymon Eshkabilov
2021 年 7 月 11 日
subplot(2,2,1);
imshow(Newforegnd);
% Use this command
axis on
...
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Read, Write, and Modify Image についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!