Hiya54 Huy
Hiya54 Huy

Reputation: 37

Removing a specified pixel in an RGB image in Matlab

Part of seam carving involves removing the seam after you've found it. If i have the seam's index, how would i go about removing it from each row of the image

image(i,remove) = [];

does not work since its got wrong dimensions. Is the only method reconstruction of the image itself?

Upvotes: 0

Views: 141

Answers (1)

Pablo Vicente Munuera
Pablo Vicente Munuera

Reputation: 49

You cannot remove a number of a matrix in matlab, without changing its dimensions (if it's an square matrix, you'll get a column array). You have two options here:

1) (Option I'd choose) Transform your matrix to a cell by using cell2mat. And on each cell you'll have the value of the pixel in each channel ({..., [r g b], ...} in a cell) or in a channel ({... ;1, 1, 1; ...}). Then you can remove a position of the cell by putting it as empty;

yourCell{indexToRemove} = [];

2) Put a value to recognise the pixel as invalid. For instance, you can use black (0, 0, 0) or white (1, 1, 1) colour in that pixel index.

I can improve any of the two options, in case you want any of them.

Upvotes: 0

Related Questions