i have a "tif" image and i want to label it, i wrote a code but i cant reach what i need!!! i still have a noisy pic? can u help me get rid of this noice?

2 次查看(过去 30 天)
my code:
A = imread("ניסוי1 חתוך.tif","tif");
A=rgb2gray(A);
t = graythresh(A);
BW1 = imbinarize(A,t);
BW2 = bwareaopen(BW1,50);
BW3 = medfilt2(BW2);
figure; imshow(BW3); title("after");
I enclose my picture in the ZIP file and what I get after activating the code.
my question is how can i get rid of this noise and get a pic like "wanted pic" that appears in the ZIP file??
  3 个评论
Sarah Nasra
Sarah Nasra 2021-11-5
just one more question!!
i want to fill the cells so i used the function "imfill" but because the borders of the cells not completed 100%, not all the cells filled.
how can i do that?
A = imread("ניסוי1 חתוך.tif","tif");
A=rgb2gray(A);
t = 0.64;
BW1 = imbinarize(A,t);
BW2 = bwareaopen(BW1,50);
BW3 = medfilt2(BW2);
BW4 = imfill(BW3,'holes');
figure; imshow(BW4); title("after");

请先登录,再进行评论。

回答(1 个)

yanqi liu
yanqi liu 2021-11-6
编辑:yanqi liu 2021-11-6
the image process as follows, the hard point is that segment
clc; clear all; close all;
img = imread('https://ww2.mathworks.cn/matlabcentral/answers/uploaded_files/791449/t.jpg');
jmg = rgb2lab(img);
jm = mat2gray(jmg(:,:,1));
bc = edge(jm, 'canny');
be = edge(jm, 'sobel');
be = bwareaopen(imfill(imclose(be, strel('disk', 5)), 'holes'),500);
bt = imerode(imopen(be, strel('disk', 30)), strel('disk', 10));
jm = mat2gray(jm .* double(bt));
bs = imbinarize(jm, 'adaptive');
figure; imshow(bs, []);
bs = imopen(bs, strel('line', 25, 0));
bs = bwareaopen(bs, 500);
[L,num] = bwlabel(bs);
stats = regionprops(L);
figure; imshow(bs, []);
figure; imshow(img, [])
hold on;
for i = 1 : num
hold on; rectangle('position', stats(i).BoundingBox, 'EdgeColor', 'r', 'LineWidth', 2)
end

类别

Help CenterFile Exchange 中查找有关 Images 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by