我正在尝试根据图像的"饱和度"为图像赋值,以查看图像是黑白还是彩色.我正在使用Imagick,并且发现了似乎是命令行的完美代码,并尝试使用PHP库复制它.
我想我理解这个概念:
convert '$image_path' -colorspace HSL -channel g -separate +channel -format '%[fx:mean]' info:
Run Code Online (Sandbox Code Playgroud)
$imagick = new Imagick($image_path);
$imagick->setColorspace(imagick::COLORSPACE_HSL);
print_r($imagick->getImageChannelMean(imagick::CHANNEL_GREEN));
Run Code Online (Sandbox Code Playgroud)
但是,我的PHP代码不会输出与命令行代码相同的值.例如,灰度图像提供0
命令行代码,但PHP代码给出[mean] => 10845.392051182 [standardDeviation] => 7367.5888849872
.
同样,另一灰度图像给出了0
对[mean] => 31380.528443457 [standardDeviation] => 19703.501101904
.
彩色图像给出了0.565309
对比[mean] => 33991.552881892 [standardDeviation] => 16254.018540044
.
在不同的值之间似乎没有任何类型的模式.我做错了什么吗?
谢谢.
刚才补充一下,我也试过这个PHP代码
$imagick = new Imagick($image_path);
$imagick->setColorspace(imagick::COLORSPACE_HSL);
$imagick->separateImageChannel(imagick::CHANNEL_GREEN);
$imagick->setFormat('%[fx:mean]');
Run Code Online (Sandbox Code Playgroud)
但是Unable to set format
当我尝试设置格式时出现错误.我也试过setFormat('%[fx:mean] info:')
,setFormat('%[mean]')
,setFormat('%mean')
,等.
自从我开始使用iOS 6后,我似乎遇到了一个问题,这在使用iOS 5时没有出现.起初,我认为它可能只是一个模拟器错误,但是自从今天在我的iPhone 5上测试它,我可以看到它不只是在模拟器中.
我正在以编程方式创建所有内容 - 我似乎更喜欢这样做(我认为这是因为我的HTML/CSS背景!) - 但我仍然是Objective-C的新手,我找不到完整的示例如何以编程方式设置导航控制器/表视图,所以我把它放在我能找到的信息块中,因此,我可能会做一些根本错误的事情.但是,它在iOS 5上完美运行(并且仍然有效).
问题是我在导航栏和表视图之间有一个黑条,但奇怪的是,如果我按下一个视图并返回到原始视图,该条消失,并且在我完全重启之前不再出现该应用程序.
下面的图片是启动时的应用程序(1),因为我正在推动(2)中的视图,以及我回到它之后的初始视图(3):
这就是我的代码:
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
RootViewController *rootController = [[RootViewController alloc] init];
self.window.rootViewController = rootController;
self.navigationController = [[UINavigationController alloc] initWithRootViewController:rootController];
[self.window addSubview:navigationController.view];
[self.window makeKeyAndVisible];
NSLog(@"Window frame: %@", NSStringFromCGRect(self.window.frame));
return YES;
}
Run Code Online (Sandbox Code Playgroud)
RootViewController.m
- (void)loadView
{
self.title = @"Title";
self.tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] bounds] style:UITableViewStylePlain];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.view = self.tableView;
NSLog(@"tableView frame: %@", NSStringFromCGRect(self.tableView.frame)); …
Run Code Online (Sandbox Code Playgroud) 我正在开发一个列出图像的应用程序,并为每个图像分配了多个标签.我希望能够找到标记有所搜索的所有标签的图像.
images
表- id
- download_url
- image_width
- image_height
Run Code Online (Sandbox Code Playgroud)
tags
表- id
- name
Run Code Online (Sandbox Code Playgroud)
image_tag
表- id
- image_id
- tag_id
Run Code Online (Sandbox Code Playgroud)
在我的模型中Image
,我已经得到了belongsToMany('Tag')
,并且在我的模型中Tags
,我得到了belongsToMany('Image')
.到目前为止,这一切都按照我的希望进行.
但是,当我尝试通过标签搜索图像时,会出现问题.我似乎能够使用以下代码进行搜索或搜索.
$tags = explode(' ', $tag_text);
$query = DB::table('images');
$query->join('image_tag', 'images.id', '=', 'image_tag.image_id');
$query->join('tags', 'tags.id', '=', 'image_tag.tag_id');
foreach ($tags as $tag)
{
$query->orWhere('tags.name', '=', $tag);
}
$result = $query->get();
Run Code Online (Sandbox Code Playgroud)
如果我搜索(例如)nyc skyscraper
,我会得到一个包含标签nyc或标签摩天大楼的图像列表.但是,我只想显示带有标签nyc和标签摩天大楼的图像.
我尝试 …
colors ×1
eloquent ×1
imagemagick ×1
imagick ×1
ios ×1
ios6 ×1
join ×1
laravel ×1
laravel-4 ×1
objective-c ×1
php ×1
uitableview ×1