c# 3.0 - image interpolation -
hi in project want give number of still images in images should take shuffling images input out put cme sequential images can compare nearest neighbor using interpolation methods how can implement plz tell me .i have code tell me how wrks.
public interpolationmethod method = interpolationmethod.bilinear; public int newwidth = 0; public int newheight = 0; try { this.newwidth = math.max(1, math.min(5000, int.parse(widthbox.text))); this.newheight = math.max(1, math.min(5000, int.parse(heightbox.text))); this.method = (methodcombo.selectedindex == 0) ? interpolationmethod.nearestneighbor : (methodcombo.selectedindex == 1) ? interpolationmethod.bilinear : interpolationmethod.bicubic; this.dialogresult = dialogresult.ok; this.close(); } catch (exception) { messagebox.show(this, "incorrect values entered", "error", messageboxbuttons.ok, messageboxicon.error); } }
start nearest neighbor interpolation -- it's simplest. basically, approach works this:
- allocate memory new image (unless it's been done you, obviously)
- iterate on pixels of new image. can in way want, common way called "scanline traversal" or "raster scan" -- read across columns first, , when last column, move down row , go first column.
- at each pixel position
(row, col), work out corresponding position(row_o, col_o)in old image. example, if old image half size,row_o = row/2,col_o = col/2. note since pixel positions integers, there rounding involved. nearest neighbor interpolation, it's necessary evil , can't avoid it. - grab pixel value @ position
(row_o, col_o)in old image - assign value new image @ position (
row, col)
- at each pixel position
once out of way, other approaches should make more sense.
scanline traversal:
for (i=0; < image.height; ++i) (j=0; j < image.width; ++j) { // stuff here } what looks like:

Comments
Post a Comment