crop objects from color image and still have color objects
Mostrar comentarios más antiguos
Hello,
I know how to crop an object from a binary image. But how to do it from a color image to get a color final image around the object.
Thnak you,
Respuestas (2)
mariem farhat
el 12 de Ag. de 2015
Abdullah Sarwar
el 14 de En. de 2021
Editada: Abdullah Sarwar
el 14 de En. de 2021
0 votos
clear all;
clc;
rgbImage = imread('04738.bmp');
% Extract color channels.
redChannel = rgbImage(:,:,1); % Red channel
greenChannel = rgbImage(:,:,2); % Green channel
blueChannel = rgbImage(:,:,3); % Blue channel
size_img=size(rgbImage);%size of img
minval=min(size_img(1:2));%min value of size matrix
if minval<128% crop dimentions
i=64
elseif minval<256
i=128
elseif minval<512
i=256
elseif minval<1024
i=512
elseif minval<2048
i=1024
end
x=redChannel(1:i,1:i);%crop red
y=greenChannel(1:i,1:i);%crop green
z=blueChannel(1:i,1:i);%crop blue
recombinedRGBImage = cat(3, x, y, z);%recombine all planes
% Display them all.
subplot(1,2,1);
imshow(rgbImage);
subplot(1,2,2);
imshow(recombinedRGBImage);
title('Recombined to Form Original RGB Image Again')
%% please make changes according to your need
Categorías
Más información sobre Blue en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!