[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #55780] [octave forge] (image) imresize with '
From: |
anonymous |
Subject: |
[Octave-bug-tracker] [bug #55780] [octave forge] (image) imresize with 'cubic' option is very wrong |
Date: |
Mon, 4 Mar 2019 13:17:25 -0500 (EST) |
User-agent: |
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0 |
Follow-up Comment #4, bug #55780 (project octave):
Carnë makes a good point, there should always be a comment when
special-casing something. Is the original author still around to explain this
special case?
If cleaning up `imremap` anyway, I suggest you also remove the redundant
segment
valid = !isna(warped);
warped(!valid) = extrapval;
This bit is repeated twice: once inside `grayinterp`, applied to each channel,
and then again after the loop over the channels in `imremap` itself. Except
that `grayinterp` is called with `extrapval=0` (is this a bug? Why not pass
`extrapval`?).
Actually, it looks like `interp2` also should be called with `extrapval`
instead of `0`, then the non-valid parts will be filled with the right value
there. Does `interp2` really return NA values if passing `extrap=0`?
Ouch! There's no pre-allocation for `warped` either!
Looking at this code without the special case, I'd remove `grayinterp`
altogether, it does nothing. I'd leave the relevant bit in `imremap` as
follows:
## Interpolate
sz = size (im);
n_planes = prod (sz(3:end));
warped = zeros(sz); % PREALLOCATE!!!!
for i = 1:n_planes
warped(:,:,i) = interp2 (double(im(:,:,i)), XI, YI, interp, extrapval); %
JUST CALL INTERP2 DIRECTLY HERE, AND USE EXTRAPVAL
endfor
## we return image on same class as input
warped = cast (warped, class (im));
When removing `graybicubic`, `bc` also becomes irrelevant (`sym_sub2ind` is
removed in the patch). The functions `isgriddata` and `isequallyspaced` are
never used in the current code, I would remove them in this patch too.
Cheers,
Cris Luengo.
_______________________________________________________
Reply to this item at:
<https://savannah.gnu.org/bugs/?55780>
_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/
- [Octave-bug-tracker] [bug #55780] [octave forge] (image) imresize with 'cubic' option is very wrong, Avinoam Kalma, 2019/03/01
- [Octave-bug-tracker] [bug #55780] [octave forge] (image) imresize with 'cubic' option is very wrong, Carnë Draug, 2019/03/04
- [Octave-bug-tracker] [bug #55780] [octave forge] (image) imresize with 'cubic' option is very wrong,
anonymous <=
- [Octave-bug-tracker] [bug #55780] [octave forge] (image) imresize with 'cubic' option is very wrong, anonymous, 2019/03/04
- [Octave-bug-tracker] [bug #55780] [octave forge] (image) imresize with 'cubic' option is very wrong, anonymous, 2019/03/04
- [Octave-bug-tracker] [bug #55780] [octave forge] (image) imresize with 'cubic' option is very wrong, anonymous, 2019/03/04
- [Octave-bug-tracker] [bug #55780] [octave forge] (image) imresize with 'cubic' option is very wrong, Carnë Draug, 2019/03/05
- [Octave-bug-tracker] [bug #55780] [octave forge] (image) imresize with 'cubic' option is very wrong, Avinoam Kalma, 2019/03/08
- [Octave-bug-tracker] [bug #55780] [octave forge] (image) imresize with 'cubic' option is very wrong, Carnë Draug, 2019/03/11
- [Octave-bug-tracker] [bug #55780] [octave forge] (image) imresize with 'cubic' option is very wrong, Avinoam Kalma, 2019/03/18
- [Octave-bug-tracker] [bug #55780] [octave forge] (image) imresize with 'cubic' option is very wrong, Carnë Draug, 2019/03/18