フィルターのクリア

how to delete first row of pixel values?

2 ビュー (過去 30 日間)
ravneet
ravneet 2014 年 10 月 31 日
コメント済み: Rik 2020 年 10 月 12 日
How can i delete or subtract the first row of pixels of an image from the complete image.

回答 (2 件)

Geoff Hayes
Geoff Hayes 2014 年 10 月 31 日
Ravneet - if you want to delete just the first row of your image, then you could do something like the following
myImage = imread('someImage.jpg');
if ndims(myImage)==3
% there are three dimensions
myImage(1,:,:) = [];
elseif ndims(myImage)==2
% there are two dimensions
myImage(1,:) = [];
end
We access all elements in the first row as either myImage(1,:,:) or as myImage(1,:) and set that row to be empty.

Image Analyst
Image Analyst 2014 年 10 月 31 日
Geoff gave you the way to delete the first row of pixels. If you want to "subtract the first row of pixels of an image from the complete image." then you can do this (untested, and for a gray scale image).
% Get size of image
[rows, columns, numberOfColorChannels] = size(grayImage);
% Extract first row:
firstRow = grayImage(1,:);
% Replicate it to form an image of the same size:
replicatedImage = double(repmat(firstRow, [rows, 1]));
% Do the subtraction
differenceImage = double(grayImage) - replicatedImage;
imshow(differenceImage, []); % Need to use [] or won't see anything.
  4 件のコメント
marie lasz
marie lasz 2020 年 10 月 12 日
Will it randomly delete the row or column? If I want to delete the selected row/column, then how can I continue?
Rik
Rik 2020 年 10 月 12 日
It will not delete anything randomly, unless you assign a random value to row or column.

サインインしてコメントする。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by