comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » RESIZE_DOIT with INTERP=1 shifts image !!!
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
RESIZE_DOIT with INTERP=1 shifts image !!! [message #51272] Fri, 10 November 2006 05:58
Josip Krizan is currently offline  Josip Krizan
Messages: 5
Registered: November 2006
Junior Member
Hi!

I have problem with applying RESIZE_DOIT procedure with bilinear resampling
on georeferenced images. It seems to me that resulting image is shifted for
half size of pixel of original image to right and down, for any rfact<1. Is
it by design or there is a bug or am i doing something wrong.
I wrote small test routine to demonstrate this. If someone can just look at
it ...

Thanks,

Code:

PRO TEST_RESIZE_DOIT
compile_opt IDL2
envi, /restore_base_save_files
envi_batch_init, log_file='batch_log.txt'

imgName = 'C:\RSI\IDL63\products\envi43\data\bhtmref.img'
RFACT = REPLICATE(1.0/3.0, 2)

ENVI_OPEN_FILE, imgName, R_FID=fidOrig
mapInfo = ENVI_GET_MAP_INFO(FID=fidOrig)

; bound rect of some region
xCImg=[100, 110]
yCImg=[300, 310]
dimsC = [-1L, xCImg[0], xCImg[1]-1, yCImg[0], yCImg[1]-1]

ENVI_CONVERT_FILE_COORDINATES, fidOrig, xCImg, yCImg, $
xCMap, yCMap, /TO_MAP

;INTERP =0
ENVI_DOIT, 'RESIZE_DOIT', FID=fidOrig, DIMS=dimsC, $
POS=0, INTERP=0, RFACT=rfact, R_FID=fidRes, /IN_MEMORY

ENVI_FILE_QUERY, fidRes, NS=ns, NL=nl

;bound rect of whole image
; as i understand: center of UL pixel is [0.5, 0.5],
; and BR is [ns-0.5, nl-0.5]

xC1Img = [0, ns]
yC1Img = [0, nl]
dimsRes=[-1L, 0, ns-1, 0, nl-1]

ENVI_CONVERT_FILE_COORDINATES, fidRes, xC1Img, yC1Img, $
xC1Map, yC1Map, /TO_MAP

dataOrig = ENVI_GET_DATA(FID=fidOrig, DIMS=dimsC, POS=0)
dataRes0 = ENVI_GET_DATA(FID=fidRes, DIMS=dimsRes, POS=0)

ENVI_FILE_MNG, ID=fidRes, /REMOVE

PRINT, '*************** NEAREST NEIGHBOURHOOD (INTERPOL=0) *******
PRINT, 'Original pixel size: ', mapInfo.PS
PRINT, 'Resized pixel size; ', mapInfo.PS * rfact
PRINT, 'delta X: ', xC1Map - xCMap
PRINT, 'delta Y: ', yC1Map - yCMap

PRINT, 'Orig. data: ', SIZE(dataOrig, /DIMENSIONS)
PRINT, dataOrig

PRINT, 'Resized data:', SIZE(dataRes, /DIMENSIONS)
PRINT, dataRes0

;INTERP = 1

ENVI_DOIT, 'RESIZE_DOIT', FID=fidOrig, DIMS=dimsC, $
POS=0, INTERP=1, RFACT=rfact, R_FID=fidRes, /IN_MEMORY

ENVI_FILE_QUERY, fidRes, NS=ns, NL=nl

;bound rect of whole image
; as i understand: center of UL pixel is [0.5, 0.5],
; and BR is [ns-0.5, nl-0.5]

xC1Img = [0, ns]
yC1Img = [0, nl]
dimsRes=[-1L, 0, ns-1, 0, nl-1]

ENVI_CONVERT_FILE_COORDINATES, fidRes, xC1Img, yC1Img, $
xC1Map, yC1Map, /TO_MAP

dataOrig = ENVI_GET_DATA(FID=fidOrig, DIMS=dimsC, POS=0)
dataRes1 = ENVI_GET_DATA(FID=fidRes, DIMS=dimsRes, POS=0)

PRINT, '*************** BILINEAR (INTERPOL=1) *************
PRINT, 'Original pixel size: ', mapInfo.PS
PRINT, 'Resized pixel size; ', mapInfo.PS * rfact
PRINT, 'delta X: ', xC1Map - xCMap
PRINT, 'delta Y: ', yC1Map - yCMap

PRINT, 'Orig. data: ', SIZE(dataOrig, /DIMENSIONS)
PRINT, dataOrig

PRINT, 'Resized data:', SIZE(dataRes, /DIMENSIONS)
PRINT, dataRes1

PRINT, 'Difference: '
PRINT, BYTE((LONG(dataRes1) - dataRes0)+20)

ENVI_BATCH_EXIT
END
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Keystrokes While IN a Graphics Window?
Next Topic: Re: RESIZE_DOIT with INTERP=1 shifts image !!!

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 13:38:59 PDT 2025

Total time taken to generate the page: 0.00518 seconds