Tôi là người mới bắt đầu trong ActionScript. Nếu tôi hiểu chính xác, DisplacementMapFilter sẽ di chuyển các pixel từ 'hình ảnh nguồn' theo màu của vị trí pixel tương ứng trong 'hình ảnh MAP'.DisplacementMapFilter hoạt động như thế nào?
Vấn đề là hình ảnh đích của tôi chứa pixel không có trong hình ảnh nguồn!
Ví dụ, tôi có một Unicolor 10 * 10 pixel 'hình ảnh nguồn' với BitmapData này:
sourceBitmap = new BitmapData(BITMAP_WIDTH, BITMAP_HEIGHT, false, 0x000002);
produce:
0 1 2 3 4 5 6 7 8 9
[002,002,002,002,002,002,002,002,002,002] Row 0
[002,002,002,002,002,002,002,002,002,002] Row 1
[002,002,002,002,002,002,002,002,002,002] Row 2
[002,002,002,002,002,002,002,002,002,002] Row 3
[002,002,002,002,002,002,002,002,002,002] Row 4
[002,002,002,002,002,002,002,002,002,002] Row 5
[002,002,002,002,002,002,002,002,002,002] Row 6
[002,002,002,002,002,002,002,002,002,002] Row 7
[002,002,002,002,002,002,002,002,002,002] Row 8
[002,002,002,002,002,002,002,002,002,002] Row 9
Bây giờ, tôi đi chuyển MAP BLACK này và tôi thêm một chút vuông BLUE:
displacementBitmap = new BitmapData(BITMAP_WIDTH,BITMAP_HEIGHT,false,0x000000);
for(i=5;i<10;i++)
for(j=5;j<10;j++)
displacementBitmap.setPixel(i,j,255);
produce:
0 1 2 3 4 5 6 7 8 9
[000,000,000,000,000,000,000,000,000,000] Row 0
[000,000,000,000,000,000,000,000,000,000] Row 1
[000,000,000,000,000,000,000,000,000,000] Row 2
[000,000,000,000,000,000,000,000,000,000] Row 3
[000,000,000,000,000,000,000,000,000,000] Row 4
[000,000,000,000,000,255,255,255,255,255] Row 5
[000,000,000,000,000,255,255,255,255,255] Row 6
[000,000,000,000,000,255,255,255,255,255] Row 7
[000,000,000,000,000,255,255,255,255,255] Row 8
[000,000,000,000,000,255,255,255,255,255] Row 9
kết quả:
displacementFilter = new DisplacementMapFilter();
displacementFilter.alpha=0;
displacementFilter.color=0;
displacementFilter.mapPoint=new Point(0,0);
displacementFilter.scaleX=1;
displacementFilter.scaleY=1;
displacementFilter.componentX = flash.display.BitmapDataChannel.BLUE;
displacementFilter.componentY = flash.display.BitmapDataChannel.BLUE;
displacementFilter.mapBitmap = displacementBitmap;
destinationBitmap = new BitmapData(BITMAP_WIDTH,BITMAP_HEIGHT,false,0xFFFFFFFF);
destinationBitmap.applyFilter(
sourceBitmap.bitmapData,
new Rectangle(0,0,BITMAP_WIDTH,BITMAP_HEIGHT),
new Point(0,0),
displacementFilter
);
produce:
0 1 2 3 4 5 6 7 8 9
[002,002,002,002,002,002,002,002,002,002] Row 0
[002,002,002,002,002,002,002,002,002,002] Row 1
[002,002,002,002,002,002,002,002,002,002] Row 2
[002,002,002,002,002,002,002,002,002,002] Row 3
[002,002,002,002,002,002,002,002,002,002] Row 4
[002,002,002,002,002,001,001,001,001,001] Row 5
[002,002,002,002,002,001,001,001,001,001] Row 6
[002,002,002,002,002,001,001,001,001,001] Row 7
[002,002,002,002,002,001,001,001,001,001] Row 8
[002,002,002,002,002,001,001,001,001,001] Row 9
Vì vậy, tôi không hiểu tại sao tôi có '001' pixel mà không tồn tại trong hình ảnh nguồn.
Cảm ơn bạn rất nhiều.
Và bây giờ, thời gian cho một plug không biết xấu hổ cho [câu hỏi] của tôi (http://stackoverflow.com/questions/9260717/displacement-map-filter-in-opencv). – karlphillip