回答
爲了填充一個黑色區域中,執行以下操作:
1)確定含有所述黑色區域的子區域,越小越好。最好的情況就是黑洞的邊界點。
2)通過在子區域內創建非黑色點的Delaunay三角剖分:
tri = DelaunayTri(x,y); %# x, y (column vectors) are coordinates of the non-black points.
3)確定的黑點,其中德洛奈三角形由:
[t, bc] = pointLocation(tri, [x_b, y_b]); %# x_b, y_b (column vectors) are coordinates of the black points
tri = tri(t,:);
4)插值:
v_b = sum(v(tri).*bc,2); %# v contains the pixel values at the non-black points, and v_b are the interpolated values at the black points.
似乎它會工作讓我試試。謝謝你的努力 –
這樣做的一個好方法是解決linear heat equation。你要做的是修正好區域像素的「溫度」(強度),讓熱量流入壞像素。一個可以通過,但有點慢,是這樣做的是重複平均圖像,然後設置好的像素回到其原始值與newImage(~badPixels) = myData(~badPixels);
。
我做以下步驟:
- 找到壞像素在圖像是零,然後擴張,以確保我們得到的一切
- 應用一個大的模糊讓我們開始更快
- 平均的圖像,然後設定好像素回其原始
- 重複步驟3
- 顯示
你可以重複平均,直至圖像停止變化,你可以使用更高的精度更小的平均內核---但是這給了良好的效果:
的代碼如下:
numIterations = 30;
avgPrecisionSize = 16; % smaller is better, but takes longer
% Read in the image grayscale:
originalImage = double(rgb2gray(imread('c:\temp\testimage.jpg')));
% get the bad pixels where = 0 and dilate to make sure they get everything:
badPixels = (originalImage == 0);
badPixels = imdilate(badPixels, ones(12));
%# Create a big gaussian and an averaging kernel to use:
G = fspecial('gaussian',[1 1]*100,50);
H = fspecial('average', [1,1]*avgPrecisionSize);
%# User a big filter to get started:
newImage = imfilter(originalImage,G,'same');
newImage(~badPixels) = originalImage(~badPixels);
% Now average to
for count = 1:numIterations
newImage = imfilter(newImage, H, 'same');
newImage(~badPixels) = originalImage(~badPixels);
end
%% Plot the results
figure(123);
clf;
% Display the mask:
subplot(1,2,1);
imagesc(badPixels);
axis image
title('Region Of the Bad Pixels');
% Display the result:
subplot(1,2,2);
imagesc(newImage);
axis image
set(gca,'clim', [0 255])
title('Infilled Image');
colormap gray
但你可以使用roifill
從圖像處理工具箱,像這樣類似的解決方案:
newImage2 = roifill(originalImage, badPixels);
figure(44);
clf;
imagesc(newImage2);
colormap gray
通知我使用的是與之前定義的相同的badPixels。
http://cs.stackexchange.com/questions/23794/interpolation-optimization-problem – Royi
- 1. 計算蟒蛇中心像素周圍區域的平均值
- 2. 平均值範圍
- 3. 向量元素範圍的平均值
- 4. ArrayIndexOutOfBoundsException從像素數組中計算平均值/平均值
- 5. R每週平均值
- 6. 每週計算平均值
- 7. 編號,找到平均周圍
- 8. cv ::非黑色像素的平均值
- 9. MySQL範圍和平均值
- 10. 去除圖像突出了圖像周圍
- 11. R生成有界隨機樣本週圍特定平均值
- 12. 找到所有周圍細胞的平均值
- 13. REGEX - 去除東西周圍的東西?
- 14. Tensorflow:如何減去平均圖像?
- 15. 如何去除html和css中元素周圍的邊框線?
- 16. MySQL移動平均值 - 4周
- 17. xsl:xml元素的平均值
- 18. 數值範圍的平均值
- 19. 由平均
- 20. 如何去除標題圖像周圍的空白區域?
- 21. 如何在圖像周圍去除此錨標記的填充?
- 22. 如何去除圖像周圍的空白?
- 23. 用圖像去除按鈕周圍的所有額外空間?
- 24. scipy.sparse矩陣:將行平均值減去非零元素
- 25. Oracle SQL - 本週的平均營業額高於去年的平均每週營業額
- 26. x的平均值的誤差線除以y的平均值
- 27. 平均排由多種因素
- 28. 平均的變量由兩個因素
- 29. 最大平均值,最小平均值和平均值
- 30. 平均週期信號
在DSP上重複:http://dsp.stackexchange.com/q/2803/590 – Chris
解決此問題:http://cs.stackexchange.com/questions/23794/interpolation-optimization-problem會做.. – Royi