how to extract unique pixels from on image?

15 views (last 30 days)
how to extract unique pixels from on image? can any one share algorithm?
  2 Comments
Image Analyst
Image Analyst on 9 Jan 2019
  1. Are your images color or gray scale?
  2. What do you mean by frames (in your comment below)? Are they different images that are part of a video sequence?
  3. What do you mean by unique? Do you mean pixels that are the only ones to have that particular gray level or color?
  4. What do you mean by "extract"? Do you want the "unique" color or gray level values put into a numerical array? Like if there are 100 unique pixels you want a 100-by-3 array or a 100-by-1 array? Or, do you want a binary image that indicates where the unique pixels are located? OR, do you want a masked image where the unique pixels are their original color or gray level, and the rest of the image is blackened?
  5. What is the "use case"? Why do you want to do this thing? What will you do once you have what the unique pixels? This will help us figure out what you really need.
voxey
voxey on 10 Jan 2019
1.Image Gray Scale
2.slides upto 200
3.unique---> same pixel sets [objects] upto entire n frames
4.extract: whatever grouped pixels [objects] . to extract
5.extracted objec[ pixels groups], upto n frames, its show 3D image?

Sign in to comment.

Accepted Answer

Stephen23
Stephen23 on 7 Jan 2019
>> I = randi(7,5,4,3) % MxNx3 image array.
I(:,:,1) =
3 2 5 5
7 3 6 3
6 7 6 4
5 6 4 5
1 1 1 6
I(:,:,2) =
7 2 5 2
7 4 5 7
2 2 1 4
3 7 7 2
6 3 7 7
I(:,:,3) =
1 2 2 1
7 2 6 1
5 6 4 7
7 6 5 7
4 6 3 3
>> U = unique(reshape(permute(I,[3,2,1]),3,[]).','rows') % unique pixels (each row = 1 pixel rgb)
U =
1 3 6
1 6 4
1 7 3
2 2 2
3 4 2
3 7 1
4 4 7
4 7 5
5 2 1
5 2 7
5 3 7
5 5 2
6 1 4
6 2 5
6 5 6
6 7 3
6 7 6
7 2 6
7 7 7
  2 Comments
voxey
voxey on 9 Jan 2019
Edited: voxey on 9 Jan 2019
my images bellow like this
1024 X 1024 X200
from above image from frame 1 to 200 extracting unique pixels? if frame 1st unique pixel same 2nd frame cover this same pixels upto n frame or? then second unique pixel extract upto n frame? how? Stephen Cobeldick ? can share idea's?
and how its store same pixel group in 1024 X 1024 X 200?
then second set of same pixel save to 1024 X 1024 X200
up to
N sam pixel group how to save?
Walter Roberson
Walter Roberson on 10 Jan 2019
Stephen's code will find the pixels that are unique over all 200 frames. It does not try to find the pixels that are unique within each frame.
I am not clear which of the two you would prefer. (Unique over the entire 200 frames is easier to process.)

Sign in to comment.

More Answers (2)

Walter Roberson
Walter Roberson on 10 Jan 2019
YourArray = imag; %using imag as a variable name is confusing because of imag() function
unique_vals = unique(YourArray(:));
num_unique = length(unique_vals);
outmap = cell(num_unique, 1);
for K = 1 : num_unique
outmap{K} = YourArray == unique_vals(K);
end
Now outmap will be a cell array with as many entries as there are values that are unique over the the entire array. Each entry in outmap will be a 1024 x 1024 x 200 array of logical, that is false in most places but true in every place that contained the correspoding unique value.
  3 Comments
Walter Roberson
Walter Roberson on 10 Jan 2019
Is the separation by grayscale intensity ? For example, perhaps intensities 40 to 73 would be one object ? If so then is there ever any overlap of intensities? Are the intensity groups known ahead of times? Is this an intensity clustering task with 6 clusters, one cluster for each of the 5 objects and a 6th cluster for the background ?
Is the separation by distance from each other in the images? For example, two cars driving on a road and you want to follow each of the cars?
If the separation is by dstance in the images, then is this an object tracking problem? For example, 5 balls bouncing, and you want to track each one, and they might overlap in some of the frames but not other frames?
voxey
voxey on 10 Jan 2019
Walter Rob,erson yes correct sir.
how to solve this ? last example 5 balls bouncing correct for my task, also this object separtion from 3D images? can you share any algorithm?

Sign in to comment.


KSSV
KSSV on 7 Jan 2019
Read about unique
I = imread(image) ;
R = I(:,:,1) ;
G = I(:,:,2) ;
B = I(:,:,3) ;
Ri = unique(R(:)) ;
  1 Comment
voxey
voxey on 9 Jan 2019
KSSV thanks for reply.
i need a help, i have 100 slides 2d Gray scale image ,from image 1 extract uniques pixels like 3 set of pixels, and extract from image 2 upto n image.
if from 1 image pixel group same pixel group n fimage save to as new image like N dimentsion ?
second set of pixel from image 1 upto n image ,save to new image like N dimentsion ?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!