ACM試題An Easy Problem
Description
As we known, data stored in the computers is in binary form. The problem we discuss now is about the positive integers and its binary form. Given a positive integer I, you task is to find out an integer J, which is the minimum integer greater than I, and the number of 1 s in whose binary form is the same as that in the binary form of I. For example, if "78" is given, we can write out its binary form, "1001110". This binary form has 4 1 s. The minimum integer, which is greater than "1001110" and also contains 4 1 s, is "1010011", i.e. "83", so you should output "83".
標簽:
Description
computers
Problem
binary
上傳時間:
2013-12-11
上傳用戶:libenshu01
I=imread('fig1.jpg');%從D盤名為myimages的文件夾中讀取。格式為jpg的圖像文件chost
J=imnoise(I,'salt & pepper',0.02);%給圖像加入均值為0,方差為0.02的淑鹽噪聲
subplot(2,4,1);
imshow(I);
title('原始圖像');
subplot(2,4,2);
imshow(J);
title('加入椒鹽噪聲之后的圖像');
%h=ones(3,3)/9; %產(chǎn)生3 × 3的全1數(shù)組
%B=conv2(J,h); %卷積運算
%采用MATLAB中的函數(shù)對噪聲干擾的圖像進行濾波
Q=wiener2(J,[3 3]); %對加噪圖像進行二維自適應(yīng)維納濾波
P=filter2(fspecial('average',3),J)/255; %均值濾波模板尺寸為3
K1=medfilt2(J,[3 3]); %進行3 × 3模板的中值濾波
K2= medfilt2(J,[5 5]); %進行5 × 5模板的中值濾波
K3= medfilt2(J,[7 7]); %進行7 × 7模板的中值濾波
K4= medfilt2(J,[9 9]); %進行9 × 9模板的中值濾波
%顯示濾波后的圖像及標題
subplot(2,4,3);
imshow(Q);
title('3 × 3模板維納濾波后的圖像');
subplot(2,4,4);
imshow(P);
title('3 × 3模板均值濾波后的圖像');
subplot(2,4,5);
imshow(K1);
title('3 × 3模板的中值濾波的圖像');
subplot(2,4,6);
imshow(K2);
title('5 × 5模板的中值濾波的圖像');
subplot(2,4, 7);
imshow(K3);
title('7 × 7模板的中值濾波的圖像');
subplot(2,4,8);
imshow(K4);
title('9 × 9模板的中值濾波的圖像');
標簽:
matlab
均值濾波
中值濾波
上傳時間:
2016-06-02
上傳用戶:wxcr_1