Clear Filters
Clear Filters

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?

1 view (last 30 days)
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 Comments
Sarah Nasra
Sarah Nasra on 5 Nov 2021
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");

Sign in to comment.

Answers (1)

yanqi liu
yanqi liu on 6 Nov 2021
Edited: yanqi liu on 6 Nov 2021
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

Categories

Find more on Images in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!