matlab那个怎样抓取系数,如何使用Sallee的代码从MATLAB中找到量化系数?(How can I find quantized coefficients from MATLAB using ...

如何使用Sallee的代码从MATLAB中找到量化系数?(How can I find quantized coefficients from MATLAB using Sallee's code?)

首先,我承认这是一个家庭作业问题。 但是,我好像被卡住了。 我需要使用Phil Sallee的JPEG工具箱 (在“更新”标题下面的表格底部列出的链接)从jpeg图像中获取所有量化系数(我将构建一个直方图,但我可以处理的那部分)得到我需要的数据)。 我有一个大约5 MB的JPEG图像,并在我通过Sallee的代码运行时获取这些数据:

image_width: 3000

image_height: 4000

image_components: 3

image_color_space: 2

jpeg_components: 3

jpeg_color_space: 3

comments: {}

coef_arrays: {[4000x3000 double] [2000x3000 double] [2000x3000 double]}

quant_tables: {[8x8 double] [8x8 double]}

ac_huff_tables: [1x2 struct]

dc_huff_tables: [1x2 struct]

optimize_coding: 0

comp_info: [1x3 struct]

progressive_mode: 0

如何从此图像中获取量化系数? 起初我尝试过这样的东西来吐出系数,这样我才能看到我在处理的东西:

pic = jpeg_read(image)

img_coef = pic.quant_tables{pic.comp_info(1).quant_tbl_no}

img_coef = pic.quant_tables{pic.comp_info(2).quant_tbl_no}

img_coef运行两次,因为上面的quant_tables数据点有两个元素。 然而,对于如此大的图像,这似乎是非常少量的系数。 在这方面,比我更有知识的人能指出我正确的方向吗? 在哪里/如何从jpeg图像中提取量化系数?

First, I admit that this is a homework question. However, I seem to be stuck. I need to get all quantized coefficients from a jpeg image using Phil Sallee's JPEG Toolbox (link listed at the bottom of the table under an "update" heading)(I'll be building a histogram, but that part I can handle once I can get to the data I need). I have a JPEG image that is about 5 MB in size and get back this data when I run it through Sallee's code:

image_width: 3000

image_height: 4000

image_components: 3

image_color_space: 2

jpeg_components: 3

jpeg_color_space: 3

comments: {}

coef_arrays: {[4000x3000 double] [2000x3000 double] [2000x3000 double]}

quant_tables: {[8x8 double] [8x8 double]}

ac_huff_tables: [1x2 struct]

dc_huff_tables: [1x2 struct]

optimize_coding: 0

comp_info: [1x3 struct]

progressive_mode: 0

How do I get the quantized coefficients from this image? At first I tried something like this to just spit out the coefficients so I could see what I was dealing with:

pic = jpeg_read(image)

img_coef = pic.quant_tables{pic.comp_info(1).quant_tbl_no}

img_coef = pic.quant_tables{pic.comp_info(2).quant_tbl_no}

img_coef is run twice because there are two elements to the quant_tables data point above. However, this seems like a very low amount of coefficients for such a large image. Can someone more knowledgeable than me in this regard point me in the right direction? Where/how do I pull the quantized coefficients from a jpeg image?

原文:https://stackoverflow.com/questions/9090997

更新时间:2020-02-14 08:51

最满意答案

这将打开一个文件,拉出亮度,Cr和Cb数组,以及两个量化数组。 然后它将亮度,Cr和Cb量化为它们自己的变量。

im = jpeg_read(image);

% Pull image information - Lum, Cb, Cr

lum = im.coef_arrays{im.comp_info(1).component_id};

cb = im.coef_arrays{im.comp_info(2).component_id};

cr = im.coef_arrays{im.comp_info(3).component_id};

% Pull quantization arrays

lqtable = im.quant_tables{im.comp_info(1).quant_tbl_no};

cqtable = im.quant_tables{im.comp_info(2).quant_tbl_no};

% Quantize above two sets of information

lqcof = quantize(lum,lum_qtable);

bqcof = quantize(cb,cho_qtable);

rqcof = quantize(cr,cho_qtable);

This will open a file, pull off the luminance, Cr and Cb arrays, and the two quantization arrays. It will then quantize luminance, Cr and Cb into their own variables.

im = jpeg_read(image);

% Pull image information - Lum, Cb, Cr

lum = im.coef_arrays{im.comp_info(1).component_id};

cb = im.coef_arrays{im.comp_info(2).component_id};

cr = im.coef_arrays{im.comp_info(3).component_id};

% Pull quantization arrays

lqtable = im.quant_tables{im.comp_info(1).quant_tbl_no};

cqtable = im.quant_tables{im.comp_info(2).quant_tbl_no};

% Quantize above two sets of information

lqcof = quantize(lum,lum_qtable);

bqcof = quantize(cb,cho_qtable);

rqcof = quantize(cr,cho_qtable);

2012-02-02

相关问答

如果您想最大限度地减少操作,可以遵循以下几点: n = 6;

k = 1:n;

result = [1 cumprod((n-k+1)./k)]

>> result

result =

1 6 15 20 15 6 1

这要求每个系数的操作非常少,因为每个系数都是利用先前计算的系数获得的。 如果考虑对称性,可以将操作次数减少大约一半: m1 = floor(n/2);

m2 = ceil(n/2);

k = 1:m2;

result =

...

“MATLAB桌面上的Mike”有一篇关于折叠单元格的文章 。 There's a post from 'Mike on the MATLAB Desktop' about folding cells.

如果您的多项式是单个变量的函数,则可以使用sym2poly如示例y^2 : syms y

p = 2*y^2+3*y+4;

c = sym2poly(p)

返回 c =

2 3 4

如果你真的想要其他顺序的系数,请使用fliplr(c) 。 如果你打算使用多项式,那么最好不要创建一个名为poly的变量,这是你可能想要使用的函数的名称。 如果您确实需要处理多个变量中的多项式,则可以在Matlab中使用MuPAD函数。 以下是如何使用MuPAD的coeff来获得它们在(

...

我怀疑通过截断系数,你已经更改了多项式。 您可以通过检查以下代码(当您在工作区中已经有x和y时)自己查看效果。 P = polyfit(x,y,8); % fitted polynomial

P2 = [-0.05446 1.088 -8.762 36.2 -80.85 94.32 -52.21 12.21 -0.0814]; % your coefficients

toString = @(x,pat)(sprintf(pat,x));

fix = @(x,pat)(str2double(to

...

您可以为此使用split功能。 使用is_past = split((d1-et),'time')> 0; 而不是is_past = (d1-et)>0; You can use split function for this purpose. Use is_past = split((d1-et),'time')> 0; instead of is_past = (d1-et)>0;

在我看来,不需要外部工具,方便的cftool可以在大多数情况下帮助您。 它将生成以下功能: function [fitresult, gof] = expfit(x, y, z)

[xData, yData, zData] = prepareSurfaceData( x, y, z );

% Set up fittype and options.

ft = fittype( 'c0 + c1.* exp(-(c2 .* x)) + c3.* (y.^1);', 'independent', {

...

这将打开一个文件,拉出亮度,Cr和Cb数组,以及两个量化数组。 然后它将亮度,Cr和Cb量化为它们自己的变量。 im = jpeg_read(image);

% Pull image information - Lum, Cb, Cr

lum = im.coef_arrays{im.comp_info(1).component_id};

cb = im.coef_arrays{im.comp_info(2).component_id};

cr = im.coef_arrays{im.comp_in

...

您可以使用lookfor搜索本地文档。 这将搜索内置函数的文档以及路径上的任何用户定义函数。 默认情况下,它将仅搜索每个函数/类的文档的第一行。 lookfor(searchString)

如果要搜索整个帮助注释块,则需要使用-all标志 lookfor(searchString, '-all')

如果搜索字符串只有一个单词,则可以使用命令语法 lookfor

lookfor -all

You can use lookfor to search the l

...

两个问题 用IMGRADIENT计算的'gmag'和'gdir'具有双数据类型。 因此,如果你想这样显示它们,MATLAB会将它们视为强度图像,并期望它们在[0 1]范围内。 因此,我们需要规范化'gmag'和'gdir',稍后会在代码中显示。 如果您希望保存这些图像,MATLAB需要UINT8数据类型,并且值必须位于[0 255]范围内。因此,在保存之前,您需要将其乘以255然后转换为UINT8。 码 image = imread('gray_image.bmp');

[gmag, gdir]

...

在聊天中,我们发现您的问题与矩阵代数有关 您想要在A_moved获得的是x坐标乘以a加上y坐标乘以一个常数b 。 你已经在M和N有这个坐标,所以你可以获得A_moved A_moved = (a*M) + (b*N);

它将保持与A相同的形状 On the chat we found that your problem was matrix algebra related What you want to obtain in A_moved is the x coordinate multipl

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值