i have an ultrasound image i want to remove the labeles on the image by using y=mx+b line to convert the pixeles above the line to black.how can i do it?
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
filename = '181.png';
img= imread(filename);
gray = im2gray(img);
for i=1:434
for j=1:634
if(j < (0.77i+235))
img(i,j) = 255;
else
img(i,j)=0;
end
end
end
subplot(2,2,1), imshow(img),title('transformed image');
Respuesta aceptada
DGM
el 2 de Feb. de 2023
There are a couple things going on here.
filename = '181.png';
img = imread(filename);
img = im2gray(img); % need to work on the right image
% use the actual image dimensions
[nrows,ncols,~] = size(img);
for row = 1:nrows
for col = 1:ncols
% image origin is NW corner, so a line which points from SW to NE
% actually has negative slope!
if row < (-0.77*col + 240)
img(row,col) = 128; % i'm using gray so it's easy to see
end
end
end
imshow(img)
This could also be done without the loops
filename = '181.png';
img = imread(filename);
img = im2gray(img); % need to work on the right image
[nrows,ncols,~] = size(img);
R = 1:nrows;
C = 1:ncols;
mask = R.' < (-0.77*C + 240);
img(mask) = 128;
imshow(img)
Alternatively, you could use a polygon mask to perform the selection. See drawpolygon() and createMask().
0 comentarios
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!