How do I solve imnoise error when inserting variables that store the single English alphabet and its background respectively which are logical image(which are binary image)??
Error using imnoise Expected input number 1, I, to be one of these types:
uint8, uint16, double, int16, single
Instead its type was logical.
Error in imnoise>ParseInputs (line 107) validateattributes(a, {'uint8','uint16','double','int16','single'}, {}, mfilename, ...
Error in imnoise (line 86) [a, code, classIn, classChanged, p3, p4] = ParseInputs(args{:});
Error in create_images_trial (line 34) Newforegnd_noise = imnoise(Newforegnd, 'gaussian',0, 0.01);
%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 Newforegnd_noise = imnoise(Newforegnd, 'gaussian',0, 0.01); %Apply noise on the background, using 0.01 standard deviation background_noise = imnoise(background, 'gaussian',0, 0.01); %Format figure name into string with font size automatically %iterates using assigned variable font_size % %d is decimal notation for the font size variable as it is in % whole number f = figure('Name','Foreground & background image before & after adding noise','NumberTitle','off'); p = uipanel('Parent',f,'BorderType','none'); p.Title = sprintf('For alphabet with font size of %d ',font_size); p.TitlePosition = 'centertop'; %divide the figure into subplot %which above is foreground of the alphabet %while the background of alphabet at below subplot(2,2,1,'Parent',p); imshow(Newforegnd); h1 = gca; h1.Visible = 'on'; title("Foreground image of the single alphabet"); subplot(2,2,2,'Parent',p); imshow(Newforegnd_noise); h2 = gca; h2.Visible = 'on'; title("Image of the single alphabet(after adding noise) "); subplot(2,2,3,'Parent',p); imshow(background); h3 = gca; h3.Visible = 'on'; title("Background of the single alphabet"); subplot(2,2,4,'Parent',p); imshow(background_noise); h4 = gca; h4.Visible = 'on'; title("Background of the single alphabet(after adding noise)");
Is that anyone could guide me what to do next for putting the gaussian noise ,the image now is in logical form,it can be grayscale it is made into binary because I separate the alphabet and its background into different variable?Thank you.
Newforegnd_noise = imnoise(double(Newforegnd), 'gaussian',0, 0.01); %Apply noise on the background, using 0.01 standard deviation background_noise = imnoise(double(background), 'gaussian',0, 0.01); % % % Newforegnd_noise = imnoise(uint8(Newforegnd*255), 'gaussian',0, 0.01); %Apply noise on the background, using 0.01 standard deviation background_noise = imnoise(uint8(background*255), 'gaussian',0, 0.01);
Matlabsolutions.com provides guaranteed satisfaction with a
commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain
experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support
to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been
empanelled after extensive research and quality check.
Matlabsolutions.com provides undivided attention to each Matlab
assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services
include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work
done at the best price in industry.