how can i create background black in rgb image?

조회 수: 1 (최근 30일)
sobana
sobana 2014년 8월 29일
답변: Image Analyst 2014년 12월 15일
i need to segment the cervical cell image...i decided to segment using watershed segmentation algorithm...in this segmentation types i have to separate cell nuclei from cytoplasm...i tried many types but i could not get output my coding and images are given
clc; clear all; close all; he=imread('E:\ME project\pap smear image.jpg'); w =imresize(he,[290 290]); imshow(w);
h = makecform('srgb2lab'); lab_he = applycform(w,h);
l = lab_he(:,:,1); figure, imshow(l), title('l'); % Converting into double % l= double(lab_he(:,:,2:3)); % % obtaining rows and columns of transformed image % nrows = size(l,1); ncols = size(l,2); % % Reshaping image taking each value column wise % ab= reshape(l,nrows*ncols,2); % No of clusters to be created with five iterations % nColors = 1; [cluster_idx, cluster_center] = kmeans(ab,nColors,'distance','sqEuclidean','Replicates',1); % Reshaping and showing the clusters % pixel_labels = reshape(cluster_idx,nrows,ncols); imshow(pixel_labels,[]), title('image labeled by cluster index'); % % creating five element array % segmented_images = cell(1); % Creating tiles for three different colors % rgb_label = repmat(pixel_labels,[1 1 3]); % Assigning clustered objects to array(segmented_image) % for k = 1:nColors color = w; color(rgb_label ~= k) = 0; segmented_images{k} = color; end %displaying different cluster objects % imshow(segmented_images{1}), title('objects in cluster 1');
% Evaluating mean of all cluster centers %
mean_cluster_value = mean(cluster_center,2);
% Sorting the mean cluster array and storing sorted index in idx %
[tmp, idx] = sort(mean_cluster_value);
n1_cluster_num = idx(1);
l = lab_he(:,:,1);
n1_idx = find(pixel_labels == n1_cluster_num);
L_n1 = l(n1_idx);
is_light_n1 = im2bw(L_n1,graythresh(L_n1));
nuclei_labels = repmat(uint8(0),[nrows ncols]);
nuclei_labels(n1_idx(is_light_n1==false)) = 1;
nuclei_labels = repmat(nuclei_labels,[1 1 3]);
n1_nuclei = w;
n1_nuclei(nuclei_labels ~= 1) = 0;
imshow(n1_nuclei), title('n1 nuclei');
h = makecform('srgb2lab'); lab = applycform(n1_nuclei,h); l1 = lab(:,:,1); figure, imshow(l1), title('l1'); I3 = imadjust(l1); hy = fspecial('sobel'); hx = hy'; Iy = imfilter(double(I3), hy, 'replicate'); Ix = imfilter(double(I3), hx, 'replicate'); gradmag = sqrt(Ix.^2 + Iy.^2); figure, imshow(gradmag,[]), title('Gradient magnitude (gradmag)')
W = imregionalmax(gradmag); figure, imshow(W), title('Regional Minima in Original Image');
L=watershed(gradmag); wr=L==0; figure,imshow(wr)
q=imadjust(gradmag); d = edge(q,'canny',.19);
ds = bwareaopen(d,15);
d1=im2double(l1); iout= d1; BW= ds; iout(:,:,1) = iout; %# Initialize red color plane iout(:,:,2) = iout(:,:,1); %# Initialize green color plane iout(:,:,3) = iout(:,:,1); %# Initialize blue color plane iout(:,:,1) = min(iout(:,:,1) + BW, 1); %# Add edges to green color plane iout(:,:,1) = min(iout(:,:,1) + BW, 1); %# Add edges to blue color plane figure, imshow(iout), title('iout');
  댓글 수: 2
sobana
sobana 2014년 8월 29일
편집: Image Analyst 2014년 8월 29일
my data sets are Hacettepe data set,Herlev data set,available in labs.fme.aegean.gr/decision/downloads...
sir please help me
sobana
sobana 2014년 8월 29일
편집: Image Analyst 2014년 8월 29일
my target is separate cell nuclei from cytoplasm i tried with many coding i didnt get wi

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

답변 (2개)

Alan Magalhães
Alan Magalhães 2014년 12월 15일
hello, how do I download the Hacettepe data set of Pap Test?

Image Analyst
Image Analyst 2014년 12월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by