Shahgee
Shahgee

Reputation: 3405

Interpolation of pixel color in an image, matlab

I have a simple question. I have image A and I want to interpolate its rgb to subpixel level.

rgb = imread('ngc6543a.jpg');    
red = rgb(:,:,1); % Red channel
green = rgb(:,:,2); % Green channel
blue = rgb(:,:,3); % Blue channel

One way to do it is to splitt it into three channels and then do interpolation for every channel. Here I have confusuion. How can I assign rows and colums.I 'm using interp2.

Red_subpixel = interp2(X,Y,red,Xq,Yq)

What are values of X,Y. What is their expression in matlab code.

Is there any other function that interpolates all channels alltogether.

Upvotes: 1

Views: 2365

Answers (1)

Dan
Dan

Reputation: 45752

To get X and Y you can use meshgrid:

[X,Y] = meshgrid(1:size(red,1), 1:size(red,2))

To see what it does try [x,y] = meshgrid(1:3,1:3) in the command line and it should be fairly apparent.

Upvotes: 2

Related Questions