0

I was scrolling through some answers of the same issue and got the following

C = num2cell(YourImage);
C(~YourImage) = {{}};

This should give a cell array in which there are empty cells ("nothing") where the background was, and cells containing 1 where the foreground was.And

imagesc(YourImage, 'AlphaData', YourImage)
colormap(gray)
set(gca, 'color', 'none')

to set the Region of interest visible,i did try it myself and didn't get a result,What am i doing wrong and the correct way to use this code.

Example of image with black background:

Example of image with black background

Tonechas
  • 13,398
  • 16
  • 46
  • 80
Project
  • 11
  • 5
  • 1
    This code cannot be run or cannot reproduce the "error" you are seeking. What exactly does "didn't get a result mean"? What exactly is the error? Are you trying to convert your image into individual cells with each cell being a single pixel, then wherever there is a black pixel you want to present this as an empty cell rather than the pixel values? What happens if you have colour image? Did you want each cell to be an array of RGB values, or did you want a 3D cell array? Please be more clear in what you're trying to achieve. – rayryeng Jun 16 '17 at 20:52
  • I'm trying to extract features STRICTLY from the lesion area which is in RGB ,and i don't want the features extraction to take black pixels into consideration,for example if i input this image and extract the mean from the red grayscale i'll receive a wrong reading because the black pixels affect it and the features i need to extract are mean,standard deviation,variance,skew,kurtosis,entropy for color. And at least the 4 texture ones using graycoprops GLCM. – Project Jun 16 '17 at 21:24
  • You haven't answered all of my questions. Please re-read what I've asked and try again. – rayryeng Jun 16 '17 at 21:24
  • What i would have wanted it to do is create blank cells where the black ones exist taking into consideration only ones with values between 1 and 255 per color channel,and what didn't get the result meant is when i tried to imshow(c) i got an error msg tried converting it to uint8,it didn't work and the rest of the code just wouldn't successfully run..Now i presume you have a good idea about the issue i'm trying to solve and it doesn't require the use of this method as long as i can successfully extract features from lesion area only. – Project Jun 16 '17 at 21:32

1 Answers1

0

The following snippet extracts the mean from the red channel with the background removed:

>> I = imread('https://i.stack.imgur.com/mI75C.png');
>> mask = rgb2gray(I) > 0;
>> red = I(:, :, 1);
>> red_avg = mean(red(:))

red_avg =

   48.0807

>> red_avg_br = mean(red(mask))

red_avg_br =

  192.3833
Tonechas
  • 13,398
  • 16
  • 46
  • 80