필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

matlab to C

조회 수: 2 (최근 30일)
eric nunes
eric nunes 2011년 6월 27일
마감: MATLAB Answer Bot 2021년 8월 20일
can anyone help me convert this matlab code in C...i have got answers where they have given me links but that is not useful at all...plz help.
code:
clc;
I=imread('b2.bmp');
figure(1),imshow(I);
I=double(I);
[M,N] = size(I);
% blue_mask = repmat([1 0; 0 0], M/2, N/2); % green_mask = repmat([0 1; 1 0], M/2, N/2); % red_mask = repmat([0 0; 0 1], M/2, N/2); % % R=I.*red_mask; % G=I.*green_mask; % B=I.*blue_mask;
B = I(1:2:end,1:2:end);
G1 = I(1:2:end,2:2:end);
G2 = I(2:2:end,1:2:end);
R = I(2:2:end,2:2:end);
G = (G1+G2)/2;
figure(2), imagesc(R);
figure(3), imagesc(G);
figure(4), imagesc(B);
final(:,:,1)=R;
final(: ,:,2)=G;
final(: ,:,3)=B;
final=double(final);
final=final*125/15;
final=uint8(final);
imshow(final)
% I = imread('b2.bmp'); % J = demosaic(I,'bggr'); % imshow(I); % figure, imshow(J);

답변 (1개)

Walter Roberson
Walter Roberson 2011년 6월 27일
As discussed in your previous question, the graphics portion of your question cannot be implemented in C by itself. The C language does not specify any mechanisms for hardware access.
Also, C is a strongly typed language, so the program cannot be written until you specify the data type that the image reading portion of your program will return.
Your code logic breaks if the image read is not an even length on both sides. C does not have the error() message facilities that MATLAB has, so what should be the proper way to crash the code if the image read in is of odd length on either side?

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by