필터 지우기
필터 지우기

how to convert pixel value to 0 and 1 only or (0 and 255) only?

조회 수: 8 (최근 30일)
yasmin ismail
yasmin ismail 2023년 10월 15일
댓글: Dyuman Joshi 2023년 10월 16일
I tried to used (rgb2gray) and (imbinarize) for each image but I cannt get only 1 and 0 value , still have 148 and others
how to fix it?
  댓글 수: 3
yasmin ismail
yasmin ismail 2023년 10월 15일
편집: Walter Roberson 2023년 10월 15일
@Dyuman Joshi thanks alot
but I got another error as following:
im = imread('Label7027_157.png');
im_gray2 = rgb2gray(im);
im_bin2 = imbinarize(im_gray2);
all(ismember(im_bin2,[0 1]),'all')
im = imread('new7027-157.png');
im_gray1 = rgb2gray(im);
im_bin1 = imbinarize(im_gray1);
all(ismember(im_bin,[0 1]),'all')
%%Jcard index
A = imread(im_bin1);
BW_groundTruth =imread('im_bin2');
similarity = jaccard(A, BW_groundTruth)
Error using imread>parse_inputs (line 504)
The file name or URL argument must be a character vector or string scalar.
Error in imread (line 342)
[source, fmt_s, extraArgs, was_cached_fmt_used] = parse_inputs(cached_fmt, varargin{:});
Error in trial2 (line 25)
A = imread(im_bin1);
how to fix it?
Image Analyst
Image Analyst 2023년 10월 15일
Don't call imread (you already did that) and don't put quotes around im_bin2 in this line:
BW_groundTruth = imread('im_bin2');
Do this instead:
BW_groundTruth = im_bin2;

댓글을 달려면 로그인하십시오.

채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 10월 15일
Use the binary images obtained via imbinarize as the input to jaccard -
im2 = imread('Label7027_157.png');
im_gray2 = rgb2gray(im2);
im_bin2 = imbinarize(im_gray2);
all(ismember(im_bin2,[0 1]),'all')
ans = logical
1
im1 = imread('new7027-157.png');
im_gray1 = rgb2gray(im1);
im_bin1 = imbinarize(im_gray1);
all(ismember(im_bin1,[0 1]),'all')
ans = logical
1
%% Jcard index
similarity = jaccard(im_bin1,im_bin2)
similarity = 0.1260
  댓글 수: 2
yasmin ismail
yasmin ismail 2023년 10월 15일
@Dyuman Joshi thanks alot for your help, my last question do you have any suugestion to improve the smilarity between the two images , i used label app to labeled crack in the original attached image(7027-157.png), then I got the labed image (label 7027_157.png) and i compared it with (new7027_157.png) .I applied jaccard index but as you know creating ground truth doesnt give accurate result although if you see the labeled and (new7027_157.png) approximatly same , so is there another way to measure similarity instead of jaccard indix , like compare number of pixels or anything else. I am not expert in image processing and new biggener in matlab. I appreciate your help
Dyuman Joshi
Dyuman Joshi 2023년 10월 16일
@yasmin ismail, That question is not related to your original question. Also, it is more related to Image processing than it is related to MATLAB. So, I will not be answering it (nor do I have enough experience with Image processing).
So, if my answer solved the questions you have asked, please consider accepting it.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by