Running a forloop to add text in the black pixels only!
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Here, 'FID' is a text file, I embed it with 'X' image by the following code.....But now I want to add the text in the black background only!...
So, my idea is to run another forloop, which will embed the text when it find the black pixels '0' and will skip the row when it find '>0' or '256' white pixels. So that, the central white object can be avoided from adding text.
Are here any forloop expert to help me with this idea???
FID = fileread('I:\New folder\ldpc.txt');
Str=uint16(FID);
x=imread('I:\New folder\watershed.bmp');
x=uint16(x);
[x_row,x_col]=size(x);
c=numel(Str);
a=1;
for i=1:x_row
for j=1:x_col
if(a<=c)
if(x(i,j)+Str(a)>255)
temp=x(i,j)+Str(a)-256;
else
temp=x(i,j)+Str(a);
end
z(i,j)=uint8(temp);
else
z(i,j)=uint8(x(i,j));
end
a=a+1;
end
end
0 Kommentare
Antworten (1)
DGM
am 20 Sep. 2021
Consider:
Str = fileread('adapthisteq.m'); % using this in place of a custom text file
x = im2uint8(imread('circles.png')); % assuming images should be uint8 scaled
% assuming that we're only modifying areas which are exactly zero
% also assuming that Str may contain values outside [0 255]
z = x.';
bpixels = find(z==0);
z(bpixels(1:numel(Str))) = mod(Str,256);
z = z.';
imshow(z)
1 Kommentar
Siehe auch
Kategorien
Mehr zu Convert Image Type finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!