- Build the mosaic image and record the co-ordinates for text() command in gobal reference axis as oppose to the local reference axis.
- Once all 8x8 mosaics are layed out on the figure, start adding text() command data at the (x,y) global positions you had recorded.
how can i combine 8*8 blocks into image after inserting text in each block?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
i have an image and i divite it into 8*8 blocks afterthat i have inserted text in each block,now i have to recombine these blocks to form proper image..plz suggest me the code...
clc;
clear all;
close all;
fontSize = 20;
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'lena.png';
fullFileName = fullfile(folder, baseFileName);
%fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
fullFileName = baseFileName;
if ~exist(fullFileName, 'file')
errorMessage = sprintf('Error: %s does not exist.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
figure,imshow ('lena.png');
a = imread(fullFileName);
a = imresize(a, [64 64]);
[rows columns numberOfColorBands] = size(a);
ca = mat2cell(a,8*ones(1,size(a,1)/8),8*ones(1,size(a,2)/8),3);
plotIndex = 1;
c1=zeros(size(a,1),size(a,2),3);
for c = 1 : size(ca, 2)
for r = 1 : size(ca, 1)
fprintf('c=%d, r=%d\n', c, r);
%subplot(8,8,plotIndex);
Text = sprintf('M');
H = vision.TextInserter(Text);
H.Color = [0.0 0.0 0];
H.FontSize = 3;
b = step(H,ca{r,c});
size(b);
% imshow(b);
c1(8*(c-1)+1:8*c,8*(r-1)+1:8*r,:) = b;
plotIndex = plotIndex + 1;
end
end
size(c1)
imshow(uint8(c1))
if true
% code
end
% gh= imagerestore(a); if true
% code
end
0 comentarios
Respuestas (2)
Muthu Annamalai
el 18 de Ag. de 2015
You have code that almost works, pending a linear transformation; I would suggest trying the 2-step recipe,
HTH
Walter Roberson
el 18 de Ag. de 2015
Have you considered using blockproc() instead the looping over mat2cell() ?
Also you would normally create your vision.TextInserter object before your loop and call it once on each block.
Ver también
Categorías
Más información sobre Convert Image Type en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!