How can I remove all black pixels from an image and use only the unique RGB values found in the image
What I'm trying to do is:
1) delete all black pixels from the image and only use the unique RGB colors found in the image
2) export each combined RGB color pixels that is unique as a separate 640x480 image
3) Convert / join these images into a movie file.
My thoughts are where you can divide my red, green and blue channels into the corresponding colors and convert them into three arrays with one column each. And start removing black pixels.
How to remove all black cell values (where R, G, B channels are 0) and only find / use unique RGB values
I added the image below and the code snippet:
resize_tmp_red=reshape(fintersect_red',[1,1200*1200])(:); %will cause array to be created / reshaped left to right and top to bottom (like reading a book) into 1 column
resize_tmp_green=reshape(fintersect_green',[1,1200*1200])(:);
resize_tmp_blue=reshape(fintersect_blue',[1,1200*1200])(:);
%How can I delete all cell values that are black (where the R,G,B channels are 0) and only find / use the RGB values that are unique in the image
for cc=1:10
repmat_rgb(:,:,1)=uint8(repmat(resize_tmp_red(cc,1),[640,480])); %creates 640x480 image of RGB taken from deleted black and unique color array.
repmat_rgb(:,:,2)=uint8(repmat(resize_tmp_green(cc,1),[640,480]));
repmat_rgb(:,:,3)=uint8(repmat(resize_tmp_blue(cc,1),[640,480]));
%imshow(repmat_rgb)
imwrite(repmat_rgb,strcat('/tmp/',sprintf('%03d', cc),'_img.png')); %creates image file
end
PS: I am using Octave 4.0, which is similar to Matlab. And yes, I will no longer see the structure of the original image. I will create a film only from the unique colors found in the image.
