基于卷积完成简单的图片锐化效果
来源:互联网 发布:cf刷烈龙软件 编辑:程序博客网 时间:2024/06/06 00:47
简单的卷积锐化效果的算子为:
activity:
public class ImageJAndroid3Activity extends Activity {
ImageView sourceImage;
ImageView destinationImage;
int[] data;
int width;
int height;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
sourceImage=(ImageView) findViewById(R.id.source);
destinationImage=(ImageView) findViewById(R.id.destination);
}
//边缘锐化
public void remove(View v){
Bitmap bitmap=BitmapFactory.decodeResource(getResources(),R.drawable.gg);
width=bitmap.getWidth();
height=bitmap.getHeight();
data=new int[width*height];
int[] outpixel=new int[width*height];
int[] sharp={-1,-1,-1,-1,9,-1,-1,-1,-1};
bitmap.getPixels(data, 0, width, 0, 0, width, height);
for(int y=0;y<height;y++){
for(int x=0;x<width;x++){
int a=data[y*width+x]>>24&0xff;
int sumred=0;
int sumgreen=0;
int sumblue=0;
int index=0;
for(int i=-1;i<=1;i++){
int newi=y+i;
if(newi<0 ||newi>=height){
newi=y;
}
for(int j=-1;j<=1;j++){
int newj=x+j;
if(newj<0 ||newj>=width){
newj=x;
}
int red=data[newi*width+newj]>>16&0xff;
int green=data[newi*width+newj]>>8&0xff;
int blue=data[newi*width+newj]&0xff;
sumred+=red*sharp[index];
sumgreen+=green*sharp[index];
sumblue+=blue*sharp[index];
index++;
}
}
outpixel[y*width+x]=judge(a)<<24|judge(sumred)<<16|judge(sumgreen)<<8|judge(sumblue);
}
}
Bitmap newBitmap=Bitmap.createBitmap(width, height,Config.RGB_565);
newBitmap.setPixels(outpixel, 0, width, 0, 0, width, height);
destinationImage.setImageBitmap(newBitmap);
}
public int judge(int number){
return number<0?0:((number>255?255:number));
}
图片锐化之后的效果是:
大家可以看到图片锐化之后,图片变的更加清晰了。
参考博客来自于:http://blog.csdn.net/jia20003/article/details/7365972
- 基于卷积完成简单的图片锐化效果
- 基于拉普拉斯算子完成图片锐化
- android图片特效处理之锐化效果
- android图片特效处理之锐化效果
- android图片特效处理之锐化效果
- android图片特效处理之锐化效果
- web前端学习笔记---利用css+filter完成简单的图片透明效果
- 基于拉普拉斯算子的图像锐化
- 基于OpenCV的Laplace图像锐化算法
- 基于拉普拉斯算子的图像锐化
- 基于卷积神经网络实现图片风格的迁移 1
- 基于卷积神经网络实现图片风格的迁移 2
- 基于卷积神经网络实现图片风格的迁移 3
- PHP中实现图片的锐化
- 基于tensorflow实现的简单卷积网络(CNN)
- 基于jQuery的图片放大效果
- 基于Laplacian算子的图像锐化及非锐化屏蔽(unsharp masking)
- 基于Jquery的图片切换八种效果效果
- sac louis vuitton soldes Ralph Lauren Polo Shirts are well known bring an end to the earth The male
- replica chanel Many Plaid shirts ambition be found among a mens wardrobe They show the neutral perso
- SQL 高级(5)
- qt 读取xml文件
- 读经典之TCPL练习三
- 基于卷积完成简单的图片锐化效果
- faux louis vuitton Burberry is one of the notable refinement brands bring an end to the world Burber
- 【学习】大数据是什么
- chanel outlet Have you been out at the markets
- chanel outlet online Spring comes quietly and softly Have you made changes among your clothing apt a
- louis vuitton soldes Balenciaga has greatly benefited the modern handbags forward making Balenciaga
- kate spade sale Are you conscious of the fact that immediately you tin purchase for many Burberry ha
- 虚拟机下ubuntu上网
- 写给系统管理员的 25 个 PHP 安全实践