Unable to perform assignment because the size of the left side is 20-by-1 and the size of the right side is 20-by-20-by-3.
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi, I need to make image with single letter. It needs to vary in terms of font size and noise using variance(later on) under the same parameter for image size. I should store the images withdifferent font sizes of the letter and display it. Please help. I have try to store it in cell array. But it said "
How could I solve this? I tried to use cell array but I failed. Thank you. I am quite confused with the array, Hope to have someone to guide me. Thank you.
%create blank image
w = 20;
h = 20;
blankImage= 255*ones(w,h,3,'uint8');
position_x = (w+1)/2;
position_y = (h+1)/2;
% % Extract the individual red, green, and blue color channels.
% redChannel = rgbImage(:, :, 1);
% greenChannel = rgbImage(:, :, 2);
% blueChannel = rgbImage(:, :, 3);
font_size = 10;
new_font = font_size + i;
font_start = 10;
font_end = 16;
total_img = font_start:2:font_end;
length(total_img)
% size_A = zeros(8, 'int8');
%function row_column =
% size_A = cell(1,pic_num);
%
for i=1:length(total_img)
for font_size = total_img(i)
A(:,:,i)= insertText(blankImage,[position_x position_y],'A','Font','Times New Roman','FontSize',font_size,'TextColor','black','BoxColor','w','BoxOpacity',0,'AnchorPoint','Center');
A(:,:,i)= rgb2gray(A(:,:,i));
A(:,:,i)= imnoise(A(:,:,i), 'gaussian', 0.01);
i = i+1;
end
end
% subplot(2,2,1);
montage(A);
% imshow(A(i+1);
axis on;
title('A uppercase with noise');
0 commentaires
Réponse acceptée
DGM
le 1 Mai 2021
I don't have CVT, so I can't test this, but insertText() is returning an RGB array and you're trying to fit it into a single page of a multipage image. If you're doing operations with a working image that doesn't start out with the right dimensions to fit in its destination, don't try to put it there until it does fit.
thispage = insertText(blankImage,[position_x position_y],'A','Font','Times New Roman','FontSize',font_size,'TextColor','black','BoxColor','w','BoxOpacity',0,'AnchorPoint','Center');
thispage = rgb2gray(thispage);
A(:,:,i) = imnoise(thispage, 'gaussian', 0.01);
5 commentaires
Image Analyst
le 1 Mai 2021
If @DGM's answer solved your problem, please click the "Accept this answer" link to give him reputation points.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with Image Processing Toolbox 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!