Calculating percentage of brown pixels over other colors in tumor

1 回表示 (過去 30 日間)
Ugur Akca
Ugur Akca 2022 年 1 月 23 日
コメント済み: Ugur Akca 2022 年 1 月 23 日
Hi everyone,
I want to calculate percentage of white signals over black ones (but just in the tumor roi). I mean the code that I am using now calculating all black pixels in picture so gives me small percantage but I need calculate just in the tumor area.
Can you help me to remove other black parts from calculations?
THANKS

採用された回答

Simon Chan
Simon Chan 2022 年 1 月 23 日
Define the tumor roi and then calculate the white pixels inside the roi:
clear;clc;
rawdata=imread('image.png');
BW = rgb2gray(rawdata);
J = imclearborder(BW); % Clear pixels in the boundary
black = sum(BW==0,'all');
white = sum(BW~=0,'all');
tiledlayout(1,2,'TileSpacing','none','Padding','none')
nexttile
imshow(rawdata,[]);
title(sprintf('Original Image, Black Pixel: %d, White Pixel: %d',black,white));
BW2=bwconvhull(J); % Finding the mask
BW3 = bwperim(BW2); % Finding the perimeter, only for figure display
[r,c]=find(BW3);
for k = 1:length(r)
rawdata(r(k),c(k),1)=255; % Set the pixels in the perimeter to red
end
black = sum((BW==0).*BW2,'all');
white = sum((BW~=0).*BW2,'all');
nexttile
imshow(rawdata);
title(sprintf('Mask Region, Black Pixel: %d, White Pixel: %d',black,white));
  1 件のコメント
Ugur Akca
Ugur Akca 2022 年 1 月 23 日
Thank you so much for your help, it is working great and right now,my results is more reasonable.

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by