- nr is the qty of rows to remove
- offset defines the upper section rows ( 1 to offset) kept in the output image
- the removed rows are "1+offset" to "offset+nr"
How to use ''offset'' to determine its position ?
13 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
marie lasz
el 13 de Oct. de 2020
Comentada: marie lasz
el 13 de Oct. de 2020
Hello,
I have this code which I got from github. First of all, I didn't get why he is replacing upper part and lower part of pixel rows? what does this upper part and lower part of pixels means here? Secondly, here offset means the position but how a value from left to right, right to left assigns to offset?
im_rem(1:offset,:,:) = im(1:offset,:,:); %replace upper part (above removed pixel rows)
im_rem(offset+1:H-nr,:,:) = im(offset+nr+1:H,:,:); %replace lower part (below removed pixel rows)
0 comentarios
Respuesta aceptada
Mathieu NOE
el 13 de Oct. de 2020
hello
the code is intened to remove rows in an image . I tested the code to check it
hope my comments are giving you the answer to your question
you can test it on an image to see the effect
files = dir('handheld*.jpg'); % as example : only jpeg files with "handheld" in the filename
% main loop
Filename = files.name;
im = imread(Filename); % save for future use
% plot original image
figure(1), imagesc(im);
% apply suggested code %
[H,L] = size(im); % size of original image
% parameters for rows removal
offset = 100; % output image / upper part : we keep rows "1" to "offset" of the original image
nr = 200; % output image / lower part : we keep only rows "1+offset+nr" to "H" (lower end of the original image)
% so basically the new image is the input image from which rows "1+offset" to "offset+nr" have been removed, which is indeed "nr" rows.
im_rem(1:offset,:,:) = im(1:offset,:,:); % upper part (above removed pixel rows)
im_rem(offset+1:H-nr,:,:) = im(offset+nr+1:H,:,:); % lower part (below removed pixel rows)
figure(2), imagesc(im_rem);
3 comentarios
Mathieu NOE
el 13 de Oct. de 2020
yes - I agree "offset" was not the best name here - a bit confusing because it has nothing to do with shift
it's more the last row of the upper section of the original image
so more or less as you say : offset is the limit value from where the removing of rows will start?
if you 'd prefer to work with "start' and 'end' indexes for upper / lower sections to be kept, that shouddn't be too difficult to do
let me know if you need further assistance
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!