我正在开发一个将彩色图像更改为灰色图像的应用程序.但是,有些图片如何出错.我不知道代码有什么问题.也许我输入的参数是错误请帮忙.
UIImage *c = [UIImage imageNamed:@"downRed.png"];
CGImageRef cRef = CGImageRetain(c.CGImage);
NSData* pixelData = (NSData*) CGDataProviderCopyData(CGImageGetDataProvider(cRef));
size_t w = CGImageGetWidth(cRef);
size_t h = CGImageGetHeight(cRef);
unsigned char* pixelBytes = (unsigned char *)[pixelData bytes];
unsigned char* greyPixelData = (unsigned char*) malloc(w*h);
for (int y = 0; y < h; y++) {
for(int x = 0; x < w; x++){
int iter = 4*(w*y+x);
int red = pixe lBytes[iter];
int green = pixelBytes[iter+1];
int blue = pixelBytes[iter+2];
greyPixelData[w*y+x] = (unsigned char)(red*0.3 + green*0.59+ blue*0.11); …Run Code Online (Sandbox Code Playgroud) 是否可以使用JavaScript确定给定图像是灰度还是彩色?
我在eclipse中使用了更新的willowgarage opencv库.我想将mat变量转换为灰度,我已经尝试了我在网上找到的所有内容,但它们并没有为我工作.
这是我的代码
package com.deneme.deneme;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
import org.opencv.android.Utils;
import org.opencv.core.Mat;
import org.opencv.imgproc.Imgproc;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
public class main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView img=(ImageView) findViewById(R.id.pic);
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.p26);
Mat imgToProcess=Utils.bitmapToMat(bmp);
//******
//right here I need to convert this imgToProcess to grayscale for future opencv processes
//******
Bitmap bmpOut = Bitmap.createBitmap(imgToProcess.cols(), imgToProcess.rows(), Bitmap.Config.ARGB_8888);
Utils.matToBitmap(imgToProcess, bmpOut);
img.setImageBitmap(bmpOut);
} …Run Code Online (Sandbox Code Playgroud) 我有一个JPG图像的文件夹,我正在尝试为一个讨人喜欢的比赛进行分类.我已经看到Python中的一些代码,我认为会在论坛上实现这一点,但是想知道是否可以在R中完成?我正在尝试将许多jpg图像的这个文件夹转换为csv文件,其中数字显示每个像素的灰度,类似于手数字识别器http://www.kaggle.com/c/digit-recognizer/
所以基本上是j中的jpg - > .csv,显示了用于分类的每个像素的灰度数.我想在它上面放一个随机森林或线性模型.
我有一个C语言源代码,用于嵌入式系统,包含每像素8位灰度图像的数据数组.我负责记录软件,我想将此源代码转换为JPEG(图像)文件.
这是一个代码示例:
const unsigned char grayscale_image[] = {
0, 0, 0, 0, 0, 0, 0, 74, 106, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159,
159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 146, 93, 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
//...
};
const unsigned int height = 41;
const unsigned int width = 20;
Run Code Online (Sandbox Code Playgroud)
以下是我的问题:(是的,复数)
我拥有以下资源:MS Visio 2010,Gimp,Paint,Java,Eclipse,MS Visual Studio 2010 Professional,wxWidgets,wxFrameBuilder,Cygwin. …
我正在使用aparapi写一个Buddhabrot分形发生器.我使OpenCL部分工作,产生一个代表每个像素的单维数组.我将最终图像的维度作为最终的整数,并编写代码来获取该数组中任意点的索引.我想将此保存为图像,我正在尝试将BufferedImage与TYPE_USHORT_GRAY一起使用.这是我到目前为止所拥有的:
BufferedImage image=new BufferedImage(VERTICAL_PIXELS, HORIZONTAL_PIXELS, BufferedImage.TYPE_USHORT_GRAY);
for(int i=0; i<VERTICAL_PIXELS; i++)
for(int k=0; k<HORIZONTAL_PIXELS; k++)
image.setRGB(k, i, normalized[getArrayIndex(k,i,HORIZONTAL_PIXELS)]);
Run Code Online (Sandbox Code Playgroud)
问题是,我不知道将RGB设置为什么.我需要做什么?
我为什么需要这个?
基本上我需要将彩色图像变成灰度.包括灰度版本的图像可能是一个解决方案,但在我的情况下空间紧张 - 我不希望我的APK太大.此外,我也想研究一些效果的像素.再次,这是为了使APK更小.
我从CCTexture2D找到了getPixel setPixel和获取图像的像素RGBA,但我想要更简单的东西.
任何帮助表示赞赏.
谢谢!
我试图找出如何使用CSS更改灰度图像的色调...
我有两个图像(一种颜色和一种灰度),并将此代码应用于:
CSS
img { width: 10pc; float: left; }
.huerotate { -webkit-filter: hue-rotate(300deg); }
Run Code Online (Sandbox Code Playgroud)
HTML:
<img alt="Test photo: Mona Lisa" src="http://upload.wikimedia.org/wikipedia/commons/thumb/e/ec/Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg/500px-Mona_Lisa%2C_by_Leonardo_da_Vinci%2C_from_C2RMF_retouched.jpg" class="huerotate" />
<img alt="Test photo: Hand" src="http://i821.photobucket.com/albums/zz137/ocnsamu/Capture-2.jpg" class="huerotate" />
Run Code Online (Sandbox Code Playgroud)
这成功更改了彩色图像,但灰度图像保持不变.
有没有办法改变灰度图像的色调,或者使用CSS另一种技术?
这里有一个演示:http://jsfiddle.net/ATpv8/
我有一个css代码,可以使整个页面灰度.
<style type="text/css">
html {
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
filter: grayscale(100%);
}
</style>
Run Code Online (Sandbox Code Playgroud)
我现在想在一个不受影响的div中嵌入一个iframe.我搜索了解决方案和fount:not selector.当我在http://www.w3.org/TR/css3-selectors/#negation上参考6.6.7时,我想我已经找到了解决方案,因为即使我把html作为我的css选择器它也可以工作
html|:not(x)
Run Code Online (Sandbox Code Playgroud)
所以我改变了代码,就像上面的代码一样,但没有改变.我担心这个问题是由我的网站设计造成的,所以我决定用最简单的HTML在jsfiddle中编码它们
<div id="abc" class="abc"><font color="red">This should be a normal text.</font></div>
<font color="red">This should be an affected text.</font>
Run Code Online (Sandbox Code Playgroud)
在CSS中
html|*:not(.abc) {
-webkit-filter: grayscale(100%);
-moz-filter: grayscale(100%);
filter: grayscale(100%); }
Run Code Online (Sandbox Code Playgroud)
链接:http://jsfiddle.net/4vxyqdye/1/ PS:在之前的版本中,我使用了:not(.abc),但所有元素都变成了灰度.
我看到官方 cwebp 文档没有指定目标色彩空间的选项 https://developers.google.com/speed/webp/docs/cwebp
因为我希望使用灰度色彩空间可以为文本图像节省一些空间。